Class: RVGP::Pta::HLedger::Output::Balance
- Defined in:
- lib/rvgp/pta/hledger.rb
Overview
An json parser, to structure the output of balance queries to hledger. This object exists, as a return value, from the RVGP::Pta::HLedger#balance method
Instance Attribute Summary collapse
-
#accounts ⇒ RVGP::Pta::BalanceAccount
readonly
The accounts, and their components, that were returned by hledger.
-
#summary_amounts ⇒ Array<RVGP::Journal::Commodity>
readonly
The sum amounts, at the end of the account output.
Attributes inherited from JsonBase
Instance Method Summary collapse
-
#initialize(json, options = {}) ⇒ Balance
constructor
Declare the registry, and initialize with the relevant options.
Constructor Details
#initialize(json, options = {}) ⇒ Balance
Declare the registry, and initialize with the relevant options
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/rvgp/pta/hledger.rb', line 68 def initialize(json, = {}) super json, raise RVGP::Pta::AssertionError unless @json.length == 2 @accounts = @json[0].collect do |json_account| # I'm not sure why there are two identical entries here, for fullname raise RVGP::Pta::AssertionError unless json_account[0] == json_account[1] RVGP::Pta::BalanceAccount.new(json_account[0], json_account[3].collect { |l| commodity_from_json l }) end @summary_amounts = @json[1].collect { |json_amount| commodity_from_json json_amount } end |
Instance Attribute Details
#accounts ⇒ RVGP::Pta::BalanceAccount (readonly)
The accounts, and their components, that were returned by hledger.
62 63 64 |
# File 'lib/rvgp/pta/hledger.rb', line 62 def accounts @accounts end |
#summary_amounts ⇒ Array<RVGP::Journal::Commodity> (readonly)
The sum amounts, at the end of the account output.
62 63 64 |
# File 'lib/rvgp/pta/hledger.rb', line 62 def summary_amounts @summary_amounts end |