Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/map_by.rb

Instance Method Summary collapse

Instance Method Details

#map_by(*args) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/map_by.rb', line 3

def map_by(*args)
  result = map do |object|
    args.map do |method|
      object.instance_eval(method.to_s)
    end
  end
  args.size > 1 ? result : result.flatten
end