Class: RFlow::Components::Clock
- Inherits:
-
RFlow::Component
- Object
- RFlow::Component
- RFlow::Components::Clock
- Defined in:
- lib/rflow/components/clock.rb
Overview
A clock. It ticks every n seconds. Get it?
Accepts config parameters:
-
name
- name of the clock, to disambiguate more than one -
tick_interval
- how long to wait between ticks
Emits Messages whose internal type is Message::Clock::Tick.
Constant Summary collapse
- DEFAULT_CONFIG =
Default configuration.
{ 'name' => 'Clock', 'tick_interval' => 1 }
Instance Attribute Summary collapse
-
#tick_port ⇒ Component::OutputPort
readonly
Outputs Message::Clock::Tick 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
#tick_port ⇒ Component::OutputPort (readonly)
Outputs Message::Clock::Tick messages.
63 |
# File 'lib/rflow/components/clock.rb', line 63 output_port :tick_port |
Instance Method Details
#configure!(config) ⇒ void
This method returns an undefined value.
RFlow-called method at startup.
77 78 79 80 |
# File 'lib/rflow/components/clock.rb', line 77 def configure!(config) @config = DEFAULT_CONFIG.merge config @tick_interval = Float(@config['tick_interval']) end |
#run! ⇒ void
This method returns an undefined value.
RFlow-called method at startup.
87 88 89 |
# File 'lib/rflow/components/clock.rb', line 87 def run! @timer = EventMachine::PeriodicTimer.new(tick_interval) { tick } end |