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: ArgParser, Composable Classes: Pipe, Sink, Source, Tube
Constant Summary collapse
- VERSION =
'0.1.5'
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Datapipes
constructor
Pass datapipes components instances.
-
#run_resource ⇒ Object
Run sources, data flow via pipe, tubes and sinks work.
Constructor Details
#initialize(args = {}) ⇒ Datapipes
Pass datapipes components instances. Each component can be composed. See detail in examples.
Pass parameters as a hash:
datapipe = Datapipes.new(source: my_source, sink: my_sink)
Or pass all:
datapipe = Datapipes.new(
source: my_source,
sink: my_sink,
tube: my_tube,
pipe: my_pipe
)
All arguments are optional. But in most case, you specify source and sink.
30 31 32 |
# File 'lib/datapipes.rb', line 30 def initialize(args = {}) @source, @sink, @tube, @pipe = *ArgParser.extract(args) 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.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/datapipes.rb', line 39 def run_resource @source.pipe = @pipe runners = @source.run_all sink = run_sink runners.each(&:join) notify_resource_ending sink.join end |