Class: QuickPep
- Inherits:
-
Object
- Object
- QuickPep
- Defined in:
- lib/quickpep.rb
Overview
Quick Personal Expenses Planner - for people too lazy to use a
spreadsheet or sfinance app
Instance Attribute Summary collapse
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
Instance Method Summary collapse
- #annual_costs ⇒ Object
-
#initialize(s, balance: 0, currency: '', debug: false) ⇒ QuickPep
constructor
A new instance of QuickPep.
- #warnings ⇒ Object
Constructor Details
#initialize(s, balance: 0, currency: '', debug: false) ⇒ QuickPep
Returns a new instance of QuickPep.
16 17 18 19 20 21 22 23 24 |
# File 'lib/quickpep.rb', line 16 def initialize(s, balance: 0, currency: '', debug: false) @balance, @currency, @debug = balance, currency, debug @warnings = [] @to_s = calc_expenses(s) warnings() if @warnings.any? end |
Instance Attribute Details
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
14 15 16 |
# File 'lib/quickpep.rb', line 14 def to_s @to_s end |
Instance Method Details
#annual_costs ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/quickpep.rb', line 26 def annual_costs() a = @date_events.map do |date, title| amount = @h[title].amount prefix = amount[0] == '+' ? '' : '-' amountx = (prefix + amount.gsub(/\D/,'')).to_f [date, title, amountx] end a.group_by {|date,title, amount| title }\ .map {|key, rows| [key, rows.map(&:last).sum]}.sort_by(&:last) end |
#warnings ⇒ Object
44 45 46 |
# File 'lib/quickpep.rb', line 44 def warnings() @warnings.each {|warning| puts warning.warn } end |