Method: Fairy::Inject::Interface#max_by
- Defined in:
- lib/fairy/client/inject.rb
#max_by(block_source, opts = nil) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/fairy/client/inject.rb', line 46 def max_by(block_source, opts = nil) pair = map(%{|v| [proc{#{block_source}}.call(v), v]}) max_by = pair.inject(%{|r, v| ((r[0] <=> v[0]) < 0) ? v : r}) def max_by.value super[1] end max_by end |