class Pipetree::Railway
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.
Constants
- Left
- Right
- Track
Tracks emitted by steps.
Public Class Methods
&(proc)
click to toggle source
# File lib/pipetree/railway/operator.rb, line 22 def self.&(proc) On.new(Right, And.new(proc)) end
<(proc)
click to toggle source
# File lib/pipetree/railway/operator.rb, line 18 def self.<(proc) On.new(Left, Stay.new(proc)) end
>(proc)
click to toggle source
# File lib/pipetree/railway/operator.rb, line 26 def self.>(proc) On.new(Right, Stay.new(proc)) end
new(*args)
click to toggle source
# File lib/pipetree/railway.rb, line 6 def initialize(*args) @steps = Array.new(*args) @index = Hash.new @inspect = Hash.new end
Public Instance Methods
call(input, options)
click to toggle source
Actual implementation of Pipetree:Railway. Yes, it's that simple!
# File lib/pipetree/railway.rb, line 13 def call(input, options) input = [Right, input] @steps.inject(input) do |(last, memo), step| step.call(last, memo, options) end end