Class: Trader::InverseConverter
- Defined in:
- lib/trade-o-matic/converters/inverse_converter.rb
Instance Attribute Summary collapse
-
#other ⇒ Object
readonly
Returns the value of attribute other.
Instance Method Summary collapse
- #apply(_value, _invert = false) ⇒ Object
- #current_rate ⇒ Object
-
#initialize(_other) ⇒ InverseConverter
constructor
A new instance of InverseConverter.
Constructor Details
#initialize(_other) ⇒ InverseConverter
Returns a new instance of InverseConverter.
5 6 7 |
# File 'lib/trade-o-matic/converters/inverse_converter.rb', line 5 def initialize(_other) @other = _other end |
Instance Attribute Details
#other ⇒ Object (readonly)
Returns the value of attribute other.
3 4 5 |
# File 'lib/trade-o-matic/converters/inverse_converter.rb', line 3 def other @other end |
Instance Method Details
#apply(_value, _invert = false) ⇒ Object
14 15 16 |
# File 'lib/trade-o-matic/converters/inverse_converter.rb', line 14 def apply(_value, _invert=false) @other.apply(_value, !_invert) end |
#current_rate ⇒ Object
9 10 11 12 |
# File 'lib/trade-o-matic/converters/inverse_converter.rb', line 9 def current_rate return nil if other.current_rate.nil? 1.0 / other.current_rate end |