Class: Trader::CompoundConverter
- Defined in:
- lib/trade-o-matic/converters/compound_converter.rb
Instance Attribute Summary collapse
-
#converters ⇒ Object
Returns the value of attribute converters.
Instance Method Summary collapse
- #apply(_value, _invert = false) ⇒ Object
-
#initialize(_converters) ⇒ CompoundConverter
constructor
A new instance of CompoundConverter.
Methods inherited from Converter
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
#converters ⇒ Object
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 |