Class: Mementus::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/mementus/processor.rb

Instance Method Summary collapse

Constructor Details

#initialize(graph, start_pipe) ⇒ Processor

Returns a new instance of Processor.



3
4
5
6
# File 'lib/mementus/processor.rb', line 3

def initialize(graph, start_pipe)
  @graph = graph
  @pipeline = [start_pipe]
end

Instance Method Details

#allObject



34
35
36
# File 'lib/mementus/processor.rb', line 34

def all
  process.to_a
end

#append_next(pipe) ⇒ Object



8
9
10
# File 'lib/mementus/processor.rb', line 8

def append_next(pipe)
  @pipeline << pipe
end

#idObject



20
21
22
# File 'lib/mementus/processor.rb', line 20

def id
  process.id
end

#inObject



48
49
50
51
# File 'lib/mementus/processor.rb', line 48

def in
  append_next(Pipes::Incoming.new)
  self
end

#in_eObject



53
54
55
56
# File 'lib/mementus/processor.rb', line 53

def in_e
  append_next(Pipes::IncomingEdges.new)
  self
end

#oneObject



24
25
26
27
28
29
30
31
32
# File 'lib/mementus/processor.rb', line 24

def one
  output = process

  if output.respond_to?(:each)
    output.first
  else
    output
  end
end

#outObject



38
39
40
41
# File 'lib/mementus/processor.rb', line 38

def out
  append_next(Pipes::Outgoing.new)
  self
end

#out_eObject



43
44
45
46
# File 'lib/mementus/processor.rb', line 43

def out_e
  append_next(Pipes::OutgoingEdges.new)
  self
end

#processObject



12
13
14
15
16
17
18
# File 'lib/mementus/processor.rb', line 12

def process
  output = nil
  @pipeline.each do |pipe|
    output = pipe.process(@graph, output)
  end
  output
end