Module: Pipetree::Flow::Operators
Overview
TODO: don’t inherit from Array, because we don’t want Array[].
Instance Method Summary collapse
- #%(proc, options = {}) ⇒ Object
-
#&(proc, options = {}) ⇒ Object
OnRight-> ? Right, input : Left, input.
-
#<(proc, options = {}) ⇒ Object
Optimize the most common steps with Stay/And objects that are faster than procs.
-
#>(proc, options = {}) ⇒ Object
TODO: test me.
- #>>(proc, options = {}) ⇒ Object
-
#_insert(step, options, original_proc, operator) ⇒ Object
:private: proc is the original step proc, e.g.
-
#index(proc) ⇒ Object
:private:.
Instance Method Details
#%(proc, options = {}) ⇒ Object
36 37 38 39 |
# File 'lib/pipetree/flow.rb', line 36 def %(proc, ={}) # no condition is needed, and we want to stay on the same track, too. _insert Stay.new(proc), , proc, "%" end |
#&(proc, options = {}) ⇒ Object
OnRight-> ? Right, input : Left, input
22 23 24 |
# File 'lib/pipetree/flow.rb', line 22 def &(proc, ={}) _insert On.new(Right, And.new(proc)), , proc, "&" end |
#<(proc, options = {}) ⇒ Object
Optimize the most common steps with Stay/And objects that are faster than procs.
17 18 19 |
# File 'lib/pipetree/flow.rb', line 17 def <(proc, ={}) _insert On.new(Left, Stay.new(proc)), , proc, "<" end |
#>(proc, options = {}) ⇒ Object
TODO: test me.
27 28 29 |
# File 'lib/pipetree/flow.rb', line 27 def >(proc, ={}) _insert On.new(Right, Stay.new(proc)), , proc, ">" end |
#>>(proc, options = {}) ⇒ Object
31 32 33 34 |
# File 'lib/pipetree/flow.rb', line 31 def >>(proc, ={}) _insert On.new(Right, ->(last, input, ) { [Right, proc.(input, )] } ), , proc, ">>" end |
#_insert(step, options, original_proc, operator) ⇒ Object
:private: proc is the original step proc, e.g. Validate.
43 44 45 46 47 48 49 50 51 |
# File 'lib/pipetree/flow.rb', line 43 def _insert(step, , original_proc, operator) = { append: true }.merge() insert!(step, ).tap do @step2proc[step] = [:name], original_proc, operator end self end |
#index(proc) ⇒ Object
:private:
54 55 56 |
# File 'lib/pipetree/flow.rb', line 54 def index(proc) # @step2proc: { <On @proc> => {proc: @proc, name: "trb.validate", operator: "&"} } on = @step2proc.find_proc(proc) and return @steps.index(on) end |