Class: Enumerator

Inherits:
Object show all
Defined in:
lib/ruby_smart/support/core_ext/ruby/enumerator.rb

Instance Method Summary collapse

Instance Method Details

#from_hash(key) ⇒ Array

returns a new array with only values from provided key. The Enumerator must be an array of hashes.

Examples:

ary = [{a: 34, b: 12}, {a: 19, c: 4}, {b: 3, c: 11}]
ary.map.from_hash(:a)
> [34, 19, nil]

Parameters:

Returns:



15
16
17
# File 'lib/ruby_smart/support/core_ext/ruby/enumerator.rb', line 15

def from_hash(key)
  map &->(item){item[key]}
end