Class: HledgerForecast::Forecast
- Inherits:
-
Object
- Object
- HledgerForecast::Forecast
- Defined in:
- lib/hledger_forecast/forecast.rb
Instance Attribute Summary collapse
-
#settings ⇒ Object
readonly
Returns the value of attribute settings.
-
#transactions ⇒ Object
readonly
Returns the value of attribute transactions.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#settings ⇒ Object (readonly)
Returns the value of attribute settings.
3 4 5 |
# File 'lib/hledger_forecast/forecast.rb', line 3 def settings @settings end |
#transactions ⇒ Object (readonly)
Returns the value of attribute transactions.
3 4 5 |
# File 'lib/hledger_forecast/forecast.rb', line 3 def transactions @transactions end |
Class Method Details
.parse(csv_string, cli_options = nil) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hledger_forecast/forecast.rb', line 5 def self.parse(csv_string, = nil) rows = CSV.parse( csv_string, headers: true, header_converters: -> (h) { h.to_s.tr("-", "_").to_sym }, converters: :numeric ) settings = Settings.parse(rows.select { |r| r[:type] == "settings" }, ) transactions = [] rows.each_with_index do |r, i| next if r[:type] == "settings" transactions << Transaction.from_row(r) rescue StandardError => e raise "CSV row #{i + 2}: #{e.}" end new(transactions, settings, rows.headers.include?(:tag)) end |
Instance Method Details
#has_tags_column? ⇒ Boolean
27 |
# File 'lib/hledger_forecast/forecast.rb', line 27 def = @has_tags_column |