Class: Datapipes::Source
- Inherits:
-
Object
- Object
- Datapipes::Source
- Includes:
- Composable
- Defined in:
- lib/datapipes/source.rb
Overview
Build your own source logic in ‘run` method. Use `produce` method to emitt data to pipe.
def run
10.times {|i| produce(i) }
end
You can use infinitie stream like:
def run
twitter_client.userstream do |event|
produce(event)
end
end
Instance Attribute Summary collapse
-
#pipe ⇒ Object
For internal uses.
Attributes included from Composable
Instance Method Summary collapse
-
#run ⇒ Object
Override in sub class.
-
#run_all ⇒ Object
For internal used.
Methods included from Composable
Instance Attribute Details
#pipe ⇒ Object
For internal uses. Do not touch.
35 36 37 |
# File 'lib/datapipes/source.rb', line 35 def pipe @pipe end |
Instance Method Details
#run ⇒ Object
Override in sub class.
21 22 |
# File 'lib/datapipes/source.rb', line 21 def run end |
#run_all ⇒ Object
For internal used.
Run accumulated sources which are set by composition. Each source works in new thread.
28 29 30 31 32 |
# File 'lib/datapipes/source.rb', line 28 def run_all @accumulated ||= [self] set_pipe @accumulated.map {|s| Thread.new { s.run } } end |