Changeset 27670

Show
Ignore:
Timestamp:
12/31/08 15:09:24 (4 years ago)
Author:
isaisstillalive
Message:
  • 各種メソッドの戻り値に、内部でのみ使用する配列が返ってしまっていたので、すべてselfで隠蔽。
Location:
lang/ruby/starframe
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/ruby/starframe/lib/starframe/sprite/collection.rb

    r27524 r27670  
    5555        @sprites << sprite 
    5656        sprite.instance_variable_set :@collection, self 
     57        self 
    5758      end 
    5859      alias << add 
     
    6263        @sprites.delete sprite 
    6364        sprite.instance_variable_set :@collection, nil 
     65        self 
    6466      end 
    6567       
     
    6769      def each &block 
    6870        @sprites.each &block 
     71        self 
    6972      end 
    7073       
     
    7780      def update 
    7881        @sprites.each &:call_update 
     82        self 
    7983      end 
    8084      # 所属している全てのスプライトの更新時イベントをコールする。 
    8185      def render 
    8286        @sprites.each &:call_render 
     87        self 
    8388      end 
    8489       
     
    8691      def render_to texture 
    8792        @sprites.each{ |sprite| sprite.render_to texture } 
     93        self 
    8894      end 
    8995    end 
  • lang/ruby/starframe/test/starframe/sprite/test_collection.rb

    r27516 r27670  
    3636    assert_equal @collection, @sprite.collection 
    3737  end 
     38  def test_collection_add_should_return_self 
     39    assert_equal @collection, @collection.add(@sprite) 
     40  end 
    3841  def test_collection_add_do_not_duplication 
    3942    @collection.add @sprite 
     43    @collection.add @sprite 
     44    assert_equal 1, @collection.size 
     45    assert_equal @collection, @sprite.collection 
     46  end 
     47  def test_collection_add 
    4048    @collection.add @sprite 
    4149    assert_equal 1, @collection.size 
     
    5462    assert_nil @sprite.collection 
    5563  end 
     64  def test_collection_delete_should_return_self 
     65    @collection.add @sprite 
     66    assert_equal @collection, @collection.delete(@sprite) 
     67  end 
    5668   
    5769  def test_collection_each 
     
    6274    end 
    6375    assert_equal [@sprite], @sprites 
     76  end 
     77  def test_collection_each_should_return_self 
     78    assert_equal @collection, @collection.each{} 
    6479  end 
    6580   
     
    88103  end 
    89104   
     105  def test_collection_update_should_return_self 
     106    assert_equal @collection, @collection.update 
     107  end 
     108  def test_collection_render_should_return_self 
     109    assert_equal @collection, @collection.render 
     110  end 
     111   
    90112  def test_collection_render_to 
    91113    @collection.add @sprite 
     
    95117     
    96118    assert_equal [:render_to, texture],  @sprite.called_methods.last 
     119  end 
     120  def test_collection_render_to_should_return_self 
     121    assert_equal @collection, @collection.render_to(nil) 
    97122  end 
    98123