Class: Terrestrial::FunctionalPipeline
- Inherits:
-
Object
- Object
- Terrestrial::FunctionalPipeline
- Defined in:
- lib/terrestrial/functional_pipeline.rb
Defined Under Namespace
Classes: Step
Class Method Summary collapse
Instance Method Summary collapse
- #append(name, func) ⇒ Object
- #call(args, &block) ⇒ Object
- #describe ⇒ Object
- #drop_until(step_name) ⇒ Object
-
#initialize(steps = []) ⇒ FunctionalPipeline
constructor
A new instance of FunctionalPipeline.
- #take_until(step_name) ⇒ Object
Constructor Details
#initialize(steps = []) ⇒ FunctionalPipeline
Returns a new instance of FunctionalPipeline.
7 8 9 |
# File 'lib/terrestrial/functional_pipeline.rb', line 7 def initialize(steps = []) @steps = steps end |
Class Method Details
Instance Method Details
#append(name, func) ⇒ Object
21 22 23 |
# File 'lib/terrestrial/functional_pipeline.rb', line 21 def append(name, func) self.class.new(@steps + [Step.new(name, func)]) end |
#call(args, &block) ⇒ Object
11 12 13 14 15 |
# File 'lib/terrestrial/functional_pipeline.rb', line 11 def call(args, &block) result = execution_result([[:input, args]], &block) [result.last.last, result] end |
#describe ⇒ Object
17 18 19 |
# File 'lib/terrestrial/functional_pipeline.rb', line 17 def describe @steps.map(&:name) end |
#drop_until(step_name) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/terrestrial/functional_pipeline.rb', line 33 def drop_until(step_name) step = @steps.detect { |step| step.name == step_name } first_step_index = @steps.index(step) + 1 steps = @steps.slice(first_step_index..-1) self.class.new(steps) end |
#take_until(step_name) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/terrestrial/functional_pipeline.rb', line 25 def take_until(step_name) step = @steps.detect { |step| step.name == step_name } last_step_index = @steps.index(step) steps = @steps.slice(0..last_step_index) self.class.new(steps) end |