Class: RVGP::Pta::HLedger::Output::JsonBase

Inherits:
Object
  • Object
show all
Defined in:
lib/rvgp/pta/hledger.rb

Overview

This is a base class from which RVGP::Pta::HLedger’s outputs inherit. This class mostly just provides helpers for dealing with the json output that hledger produces.

Direct Known Subclasses

Balance, Register

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, options) ⇒ JsonBase

Declare the class, and initialize with the relevant options

Parameters:

  • json (String)

    The json that was produced by hledger, to construct this object

  • options (Hash)

    Additional options

Options Hash (options):



35
36
37
38
# File 'lib/rvgp/pta/hledger.rb', line 35

def initialize(json, options)
  @pricer = options[:pricer] || RVGP::Journal::Pricer.new
  @json = JSON.parse json, symbolize_names: true
end

Instance Attribute Details

#jsonJson (readonly)

a parsed representation of the output from hledger

Returns:

  • (Json)

    the current value of json



28
29
30
# File 'lib/rvgp/pta/hledger.rb', line 28

def json
  @json
end

#pricerRVGP::Journal::Pricer (readonly)

A price exchanger, to use for any currency exchange lookups

Returns:



28
29
30
# File 'lib/rvgp/pta/hledger.rb', line 28

def pricer
  @pricer
end