Class: RFlow::Components::GenerateIntegerSequence
- Inherits:
-
RFlow::Component
- Object
- RFlow::Component
- RFlow::Components::GenerateIntegerSequence
- Defined in:
- lib/rflow/components/integer.rb
Overview
An integer sequence generator that ticks every n seconds.
Accepts config parameters:
-
start- the number to start at (defaults to0) -
finish- the number to finish at (defaults to0; no numbers greater than this will be emitted) -
step- the number to step (defaults to1) -
interval_seconds- how long to wait, in seconds, between ticks (defaults to0)
Emits Messages whose internal type is Message::Data::Integer.
Instance Attribute Summary collapse
-
#even_odd_out ⇒ Component::OutputPort
readonly
Outputs the same messages as #out.
-
#out ⇒ Component::OutputPort
readonly
Outputs Message::Data::Integer messages.
Attributes inherited from RFlow::Component
#name, #ports, #shard, #uuid, #worker
Instance Method Summary collapse
-
#configure!(config) ⇒ void
RFlow-called method at startup.
-
#run! ⇒ void
RFlow-called method at startup.
Methods inherited from RFlow::Component
build, #cleanup!, #initialize, input_port, #input_ports, output_port, #output_ports, #process_message, #shutdown!, #to_s
Constructor Details
This class inherits a constructor from RFlow::Component
Instance Attribute Details
#even_odd_out ⇒ Component::OutputPort (readonly)
Outputs the same messages as #out. Also addressable with subports even and odd to select those subsequences.
39 |
# File 'lib/rflow/components/integer.rb', line 39 output_port :even_odd_out |
#out ⇒ Component::OutputPort (readonly)
Outputs Message::Data::Integer messages.
34 |
# File 'lib/rflow/components/integer.rb', line 34 output_port :out |
Instance Method Details
#configure!(config) ⇒ void
This method returns an undefined value.
RFlow-called method at startup.
44 45 46 47 48 49 50 |
# File 'lib/rflow/components/integer.rb', line 44 def configure!(config) @start = config['start'].to_i @finish = config['finish'].to_i @step = config['step'] ? config['step'].to_i : 1 # If interval seconds is not given, it will default to 0 @interval_seconds = config['interval_seconds'].to_i end |
#run! ⇒ void
This method returns an undefined value.
RFlow-called method at startup.
54 55 56 57 58 |
# File 'lib/rflow/components/integer.rb', line 54 def run! # Note that this uses the timer (sometimes with 0 interval) so as # not to block the reactor. @timer = EM::PeriodicTimer.new(@interval_seconds) { generate } end |