lib/more_math/ranking_common.rb
# Does something similar to #each. It doesn't create new
# instances (less overhead) for every iteration step, but yields to a
# modified self instead. This is useful if one only wants to call a
# method on the yielded value and work with the result of this call. It's
# not a good idea to put the yielded values in a data structure because all
# of them will reference the same (this!) instance. If you want to do this
# use #each.
Does something similar to #each. It doesn't create new
instances (less overhead) for every iteration step, but yields to a
modified self instead. This is useful if one only wants to call a
method on the yielded value and work with the result of this call. It's
not a good idea to put the yielded values in a data structure because all
of them will reference the same (this!) instance. If you want to do this
use #each.
Does something similar to #each . It doesn ' t create new instances ( less overhead ) for every iteration step but yields to a modified self instead . This is useful if one only wants to call a method on the yielded value and work with the result of this call . It ' s not a good idea to put the yielded values in a data structure because all of them will reference the same ( this! ) instance . If you want to do this use #each .
def each!
      old_rank = rank
      0.upto(last) do |r|
        self.rank = r
        yield self
      end
      self
    ensure
      self.rank = old_rank
    end
def each! old_rank = rank 0 . upto ( last ) do | r | self . rank = r yield self end self ensure self . rank = old_rank end
Does something similar to #each.
Does something similar to #each .