Class: Trader::CompoundConverter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Converter

#current_rate

Constructor Details

#initialize(_converters) ⇒ CompoundConverter

Returns a new instance of CompoundConverter.



5
6
7
# File 'lib/trade-o-matic/converters/compound_converter.rb', line 5

def initialize(_converters)
  @converters = _converters
end

Instance Attribute Details

#convertersObject

Returns the value of attribute converters.



3
4
5
# File 'lib/trade-o-matic/converters/compound_converter.rb', line 3

def converters
  @converters
end

Instance Method Details

#apply(_value, _invert = false) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/trade-o-matic/converters/compound_converter.rb', line 9

def apply(_value, _invert=false)
  unless _invert
    converters.inject(_value) { |r, c| c.apply(r, false) }
  else
    converters.reverse.inject(_value) { |r, c| c.apply(r, true) }
  end
end