Class: Datapipes
- Inherits:
-
Object
- Object
- Datapipes
- Defined in:
- lib/datapipes.rb,
lib/datapipes/pipe.rb,
lib/datapipes/sink.rb,
lib/datapipes/tube.rb,
lib/datapipes/source.rb,
lib/datapipes/version.rb,
lib/datapipes/composable.rb
Defined Under Namespace
Modules: Composable Classes: Pipe, Sink, Source, Tube
Constant Summary collapse
- VERSION =
'0.1.4'
Instance Method Summary collapse
-
#initialize(source, sink, tube: Tube.new, pipe: Pipe.new) ⇒ Datapipes
constructor
Pass datapipes components instances.
-
#run_resource ⇒ Object
Run sources, data flow via pipe, tubes and sinks work.
Constructor Details
#initialize(source, sink, tube: Tube.new, pipe: Pipe.new) ⇒ Datapipes
Pass datapipes components instances. Each component can be composed. See detail in examples.
tube and pipe are optional. If not given tube, a default tube which takes no effect is used.
17 18 19 20 21 22 |
# File 'lib/datapipes.rb', line 17 def initialize(source, sink, tube: Tube.new, pipe: Pipe.new) @source = source @tube = tube @sink = sink @pipe = pipe end |
Instance Method Details
#run_resource ⇒ Object
Run sources, data flow via pipe, tubes and sinks work. Everything work with just call this method.
When all sources finished producing, and all sinks did their jobs, this method returns.
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/datapipes.rb', line 29 def run_resource @source.pipe = @pipe runners = @source.run_all consumer = run_comsumer runners.each(&:join) notify_resource_ending consumer.join end |