Class: Pipetree::Railway
- Inherits:
-
Object
- Object
- Pipetree::Railway
- Defined in:
- lib/pipetree/railway/operator.rb,
lib/pipetree/railway.rb
Overview
Optimize the most common steps with Stay/And objects that are faster than procs. This is experimental API and might be removed/changed without prior warning.
Defined Under Namespace
Modules: Add, Inspect, Operator Classes: And, On, Stay, Strut
Constant Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#call(input, options) ⇒ Object
Actual implementation of Pipetree:Railway.
-
#initialize(*args) ⇒ Railway
constructor
A new instance of Railway.
Methods included from Inspect
#inspect, #inspect_func, #inspect_line, #inspect_row, #inspect_rows
Methods included from Add
Constructor Details
#initialize(*args) ⇒ Railway
Returns a new instance of Railway.
6 7 8 9 10 |
# File 'lib/pipetree/railway.rb', line 6 def initialize(*args) @steps = Array.new(*args) @index = Hash.new @inspect = Hash.new end |
Class Method Details
.&(proc) ⇒ Object
22 23 24 |
# File 'lib/pipetree/railway/operator.rb', line 22 def self.&(proc) On.new(Right, And.new(proc)) end |
Instance Method Details
#call(input, options) ⇒ Object
Actual implementation of Pipetree:Railway. Yes, it’s that simple!
13 14 15 16 17 18 19 |
# File 'lib/pipetree/railway.rb', line 13 def call(input, ) input = [Right, input] @steps.inject(input) do |(last, memo), step| step.call(last, memo, ) end end |