Class: RVGP::Pta::HLedger::Output::Balance

Inherits:
JsonBase
  • Object
show all
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

Attributes inherited from JsonBase

#json, #pricer

Instance Method Summary collapse

Constructor Details

#initialize(json, options = {}) ⇒ Balance

Declare the registry, and initialize with the relevant options

Parameters:

Raises:



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, options = {})
  super json, options

  raise RVGP::Pta::AssertionError unless @json.length == 2

  @accounts = @json[0].collect do ||
    # I'm not sure why there are two identical entries here, for fullname
    raise RVGP::Pta::AssertionError unless [0] == [1]

    RVGP::Pta::BalanceAccount.new([0],
                                  [3].collect { |l| commodity_from_json l })
  end

  @summary_amounts = @json[1].collect { |json_amount| commodity_from_json json_amount }
end

Instance Attribute Details

#accountsRVGP::Pta::BalanceAccount (readonly)

The accounts, and their components, that were returned by hledger.

Returns:



62
63
64
# File 'lib/rvgp/pta/hledger.rb', line 62

def accounts
  @accounts
end

#summary_amountsArray<RVGP::Journal::Commodity> (readonly)

The sum amounts, at the end of the account output.

Returns:



62
63
64
# File 'lib/rvgp/pta/hledger.rb', line 62

def summary_amounts
  @summary_amounts
end