Class: Artoo::Drivers::Random
- Defined in:
- lib/artoo/drivers/random.rb
Overview
Test driver to obtain a random number
Constant Summary collapse
- COMMANDS =
[:random].freeze
Instance Attribute Summary
Attributes inherited from Driver
Instance Method Summary collapse
- #random ⇒ Object
-
#start_driver ⇒ Object
Publishes event to update event topic with random number.
Methods inherited from Driver
#command, #commands, #connection, #event_topic_name, #initialize, #interval, #known_command?, #method_missing, #pin
Constructor Details
This class inherits a constructor from Artoo::Drivers::Driver
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Artoo::Drivers::Driver
Instance Method Details
#random ⇒ Object
22 23 24 |
# File 'lib/artoo/drivers/random.rb', line 22 def random @number end |
#start_driver ⇒ Object
Publishes event to update event topic with random number
12 13 14 15 16 17 18 19 20 |
# File 'lib/artoo/drivers/random.rb', line 12 def start_driver every(interval) do @number = rand(100000) publish(event_topic_name("update"), "random", @number) publish(event_topic_name("random"), @number) end super end |