Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/modesty/core_ext/array.rb
Instance Method Summary collapse
Instance Method Details
#hashmap ⇒ Object
16 17 18 19 20 |
# File 'lib/modesty/core_ext/array.rb', line 16 def hashmap self.map do |e| [e, yield(e)] end.to_h end |
#histogram ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/modesty/core_ext/array.rb', line 3 def histogram hsh = Hash.new(0) self.each do |e| hsh[e] += 1 end hsh end |
#to_h ⇒ Object
12 13 14 |
# File 'lib/modesty/core_ext/array.rb', line 12 def to_h Hash[self] end |