Class: SimplePipeline
- Inherits:
-
Object
- Object
- SimplePipeline
- Defined in:
- lib/simple_pipeline.rb,
lib/simple_pipeline/timeout.rb,
lib/simple_pipeline/version.rb
Defined Under Namespace
Modules: Timeout
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
- #add(pipe) ⇒ Object
-
#initialize ⇒ SimplePipeline
constructor
A new instance of SimplePipeline.
- #process(payload) ⇒ Object
- #size ⇒ Object (also: #length)
Constructor Details
#initialize ⇒ SimplePipeline
Returns a new instance of SimplePipeline.
7 8 9 |
# File 'lib/simple_pipeline.rb', line 7 def initialize @pipes = [] end |
Instance Method Details
#add(pipe) ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/simple_pipeline.rb', line 11 def add (pipe) begin raise ArgumentError, "invalid pipe - incorrect number of arguments for process() method (should be 1)" unless pipe.class.instance_method(:process).arity == 1 rescue NameError raise ArgumentError, "invalid pipe - process() method not found" end @pipes << pipe end |
#process(payload) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/simple_pipeline.rb', line 25 def process (payload) @pipes.each do |pipe| if pipe.is_a? SimplePipeline::Timeout pipe.process_with_timeout(payload) else pipe.process(payload) end end end |
#size ⇒ Object Also known as: length
21 22 23 |
# File 'lib/simple_pipeline.rb', line 21 def size return @pipes.size end |