Class: Pipetree::Flow

Inherits:
Object
  • Object
show all
Includes:
Inspect, Operators, Pipetree::Function::Insert::Macros
Defined in:
lib/pipetree/flow.rb

Defined Under Namespace

Modules: Inspect, Operators Classes: And, On, Stay, StepMap

Constant Summary collapse

Left =

Directions emitted by steps.

Class.new
Right =
Class.new

Instance Method Summary collapse

Methods included from Pipetree::Function::Insert::Macros

#insert!

Methods included from Operators

#%, #&, #<, #>, #>>, #_insert, #index

Methods included from Inspect

#inspect_func, #inspect_line, #inspect_row, #inspect_rows

Methods included from Inspect

#inspect, #inspect_func, #inspect_line, #inspect_object, #inspect_proc, #inspect_row, #inspect_rows

Constructor Details

#initialize(*args) ⇒ Flow

Returns a new instance of Flow.



8
9
10
11
# File 'lib/pipetree/flow.rb', line 8

def initialize(*args)
  @steps     = Array.new(*args)
  @step2proc = StepMap.new
end

Instance Method Details

#call(input, options) ⇒ Object

Actual implementation of Pipetree:Flow. Yes, it’s that simple!



65
66
67
68
69
70
71
72
# File 'lib/pipetree/flow.rb', line 65

def call(input, options)
  input = [Right, input]

  @steps.inject(input) do |memooo, step|
    last, memo = memooo
    step.call(last, memo, options)
  end
end