module Enumerable
Extends Ruby’s own Enumrable module with method max_by? for Ruby < 1.8.7
@author Sebastian Staudt @since 0.6.0
Public Instance Methods
max_by(&block)
click to toggle source
Returns the object in enum that gives the maximum value from the given block.
@yield [obj] The block to call on each element in the enum @yieldparam [Object] obj A single object in the enum @yieldreturn [Comparable] A value that can be compared (+<=>+) with the
values of the other objects in the enum
# File lib/core_ext/enumerable.rb, line 21 def max_by(&block) max { |a , b| block.call(a) <=> block.call(b) } end