Class: Tableasy::Total

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

Instance Method Summary collapse

Constructor Details

#initialize(list) ⇒ Total

Returns a new instance of Total.



5
6
7
# File 'lib/tableasy/total.rb', line 5

def initialize(list)
  @list = list
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(column) ⇒ Object



9
10
11
# File 'lib/tableasy/total.rb', line 9

def method_missing(column)
  @list.collect {|item| item.send(column) }.inject {|total, item| total + item }
end