Class: Trader::InverseConverter

Inherits:
Converter show all
Defined in:
lib/trade-o-matic/converters/inverse_converter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#otherObject (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_rateObject



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