Class: Trader::FixedConverter
- Defined in:
- lib/trade-o-matic/converters/fixed_converter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#rate ⇒ Object
readonly
Returns the value of attribute rate.
Instance Method Summary collapse
- #apply(_value, _invert = false) ⇒ Object
- #current_rate ⇒ Object
-
#initialize(_rate) ⇒ FixedConverter
constructor
A new instance of FixedConverter.
Constructor Details
#initialize(_rate) ⇒ FixedConverter
Returns a new instance of FixedConverter.
5 6 7 8 |
# File 'lib/trade-o-matic/converters/fixed_converter.rb', line 5 def initialize(_rate) @rate = _rate # TODO: maybe require rate to be a Standard.amount end |
Instance Attribute Details
#rate ⇒ Object (readonly)
Returns the value of attribute rate.
3 4 5 |
# File 'lib/trade-o-matic/converters/fixed_converter.rb', line 3 def rate @rate end |
Instance Method Details
#apply(_value, _invert = false) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/trade-o-matic/converters/fixed_converter.rb', line 14 def apply(_value, _invert=false) if _invert _value / rate else _value * rate end end |
#current_rate ⇒ Object
10 11 12 |
# File 'lib/trade-o-matic/converters/fixed_converter.rb', line 10 def current_rate rate end |