Class: Pocolog::Upgrade::Ops::Sequence
- Defined in:
- lib/pocolog/upgrade/ops/sequence.rb
Overview
A class that applies a list of operations in sequence
Instance Attribute Summary collapse
-
#ops ⇒ Object
readonly
The operations to apply, along with their intermdiate values.
Attributes inherited from Base
Instance Method Summary collapse
- #convert(value) ⇒ Object
-
#initialize(ops, to_type) ⇒ Sequence
constructor
A new instance of Sequence.
Methods inherited from Base
Constructor Details
#initialize(ops, to_type) ⇒ Sequence
Returns a new instance of Sequence
9 10 11 12 13 14 |
# File 'lib/pocolog/upgrade/ops/sequence.rb', line 9 def initialize(ops, to_type) super(to_type) @ops = ops.map do |op| [op, op.to_type.new] end end |
Instance Attribute Details
#ops ⇒ Object (readonly)
The operations to apply, along with their intermdiate values
7 8 9 |
# File 'lib/pocolog/upgrade/ops/sequence.rb', line 7 def ops @ops end |
Instance Method Details
#convert(value) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/pocolog/upgrade/ops/sequence.rb', line 16 def convert(value) ops.inject(value) do |v, (op, op_value)| op.call(op_value, v) op_value end end |