Class: Pomodoro::Formats::Review::Plugins::Expenses::Expenses

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/pomodoro/formats/review/plugins/expenses.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expenses) ⇒ Expenses

Returns a new instance of Expenses.


105
106
107
# File 'lib/pomodoro/formats/review/plugins/expenses.rb', line 105

def initialize(expenses)
  @expenses = expenses
end

Instance Attribute Details

#expensesObject (readonly)

Returns the value of attribute expenses


104
105
106
# File 'lib/pomodoro/formats/review/plugins/expenses.rb', line 104

def expenses
  @expenses
end

Instance Method Details

#totalsObject


109
110
111
112
113
# File 'lib/pomodoro/formats/review/plugins/expenses.rb', line 109

def totals
  @expenses.group_by(&:currency).reduce(Hash.new) do |buffer, (currency, expenses)|
    buffer.merge(currency => expenses.sum(&:total))
  end
end