Class: RVGP::Journal::Pricer::Price
- Inherits:
-
Base::Reader
- Object
- Base::Reader
- RVGP::Journal::Pricer::Price
- Defined in:
- lib/rvgp/journal/pricer.rb
Overview
This class represents a line, parsed from a prices journal. And, an instance of this class represents an exchange rate. This class contains a datetime, an amount, and two codes.
Instance Attribute Summary collapse
-
#amount ⇒ RVGP::Journal::Commodity
readonly
The ratio of lcode, to rcode.
-
#at ⇒ Time
readonly
The time at which this exchange rate was declared in effect.
-
#lcode ⇒ String
readonly
The character alphabetic code, or symbol for the left side of the exchange pair.
-
#rcode ⇒ String
readonly
The character alphabetic code, or symbol for the right side of the exchange pair.
Attributes inherited from Base::Reader
Class Method Summary collapse
-
.to_key(code1, code2) ⇒ String
Create a string, for this pair, that is unique to the codes, regardless of the order in which they’re provided.
Instance Method Summary collapse
-
#to_key ⇒ String
A shortcut, to Price.to_key, if a caller is looking to use this price in a Hash.
Methods inherited from Base::Reader
Instance Attribute Details
#amount ⇒ RVGP::Journal::Commodity (readonly)
The ratio of lcode, to rcode. Aka: The exchange rate.
33 34 35 |
# File 'lib/rvgp/journal/pricer.rb', line 33 def amount @amount end |
#at ⇒ Time (readonly)
The time at which this exchange rate was declared in effect
33 34 35 |
# File 'lib/rvgp/journal/pricer.rb', line 33 def at @at end |
#lcode ⇒ String (readonly)
The character alphabetic code, or symbol for the left side of the exchange pair
33 34 35 |
# File 'lib/rvgp/journal/pricer.rb', line 33 def lcode @lcode end |
#rcode ⇒ String (readonly)
The character alphabetic code, or symbol for the right side of the exchange pair. This code should (always?) match the amount.code
33 34 35 |
# File 'lib/rvgp/journal/pricer.rb', line 33 def rcode @rcode end |
Class Method Details
.to_key(code1, code2) ⇒ String
Create a string, for this pair, that is unique to the codes, regardless of the order in which they’re provided. This enables us to assert bidirectionality in the lookup of prices.
47 48 49 |
# File 'lib/rvgp/journal/pricer.rb', line 47 def self.to_key(code1, code2) [code1, code2].sort.join(' ') end |