Class: Artoo::Drivers::Pinger2

Inherits:
Driver
  • Object
show all
Defined in:
lib/artoo/drivers/pinger2.rb

Overview

Pings itself

Constant Summary collapse

COMMANDS =
[:ping].freeze

Instance Attribute Summary

Attributes inherited from Driver

#parent

Instance Method Summary collapse

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

#pingObject



22
23
24
# File 'lib/artoo/drivers/pinger2.rb', line 22

def ping
  "pong"
end

#start_driverObject

Publishes events to update and alive event topics with random number



12
13
14
15
16
17
18
19
20
# File 'lib/artoo/drivers/pinger2.rb', line 12

def start_driver
  every(interval) do
    @count = rand(100000)
    publish(event_topic_name("update"), "alive", @count)
    publish(event_topic_name("alive"), @count)
  end

  super
end