Class: BSFlow::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/bsflow/pipeline.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, procs: []) ⇒ Pipeline

Returns a new instance of Pipeline.



3
4
5
# File 'lib/bsflow/pipeline.rb', line 3

def initialize(*args, procs: [])
  @procs = args + procs
end

Instance Method Details

#call(*args) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/bsflow/pipeline.rb', line 7

def call(*args)
  output = @procs[0].call(*args)
  if @procs.length == 1
    return output
  else
    @procs[1..-1].each do |proc|
      output = proc.call(output)
    end
    output
  end
end