Class: Array::Groups

Inherits:
Hash
  • Object
show all
Defined in:
lib/appswarm/tools.rb

Instance Method Summary collapse

Methods inherited from Hash

#map_to_a, #map_to_h, #select, #select_to_a

Instance Method Details

#max_by_value(&block) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/appswarm/tools.rb', line 109

def max_by_value(&block)
  r={}
  each{|k,vs|
    value=nil
    vs.each{|e|
      curValue=block.call(e)
      value||=curValue
      value=[curValue,value].max
    }
    r[k]=value
  }
  r
end