Class: Trader::FixedConverter

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

Direct Known Subclasses

SyncConverter

Instance Attribute Summary collapse

Instance Method Summary collapse

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

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



10
11
12
# File 'lib/trade-o-matic/converters/fixed_converter.rb', line 10

def current_rate
  rate
end