Method: Enumerable#hashify
- Defined in:
- lib/jinx/helpers/enumerable.rb
#hashify ⇒ Hash
Returns a new Hash generated from this Enumerable and an optional value generator block. This Enumerable contains the Hash keys. If the value generator block is given to this method then the block is called with each enumerated element as an argument to generate the associated hash value. If no block is given, then the values are nil.
14 15 16 17 18 |
# File 'lib/jinx/helpers/enumerable.rb', line 14 def hashify hash = {} each { |item| hash[item] = yield item if block_given? } hash end |