Class: Artoo::Drivers::Driver
- Inherits:
-
Object
- Object
- Artoo::Drivers::Driver
- Includes:
- Celluloid, Celluloid::Notifications
- Defined in:
- lib/artoo/drivers/driver.rb
Overview
The Driver class is the base class used to
implement behavior for a specific kind of hardware devices. Examples would be an Arduino, a Sphero, or an ARDrone.
Derive a class from this class, in order to implement behavior for a new type of hardware device.
Direct Known Subclasses
Ardrone, ArdroneNavigation, ArdroneVideo, Button, Led, Motor, Passthru, Pinger, Pinger2, Roomba, Servo, Sphero, Wiidriver
Instance Attribute Summary collapse
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #connection ⇒ Object
- #event_topic_name(event) ⇒ Object
-
#initialize(params = {}) ⇒ Driver
constructor
A new instance of Driver.
- #interval ⇒ Object
- #method_missing(method_name, *arguments, &block) ⇒ Object
- #pin ⇒ Object
- #start_driver ⇒ Object
Methods included from Celluloid
Constructor Details
#initialize(params = {}) ⇒ Driver
Returns a new instance of Driver.
15 16 17 |
# File 'lib/artoo/drivers/driver.rb', line 15 def initialize(params={}) @parent = params[:parent] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/artoo/drivers/driver.rb', line 39 def method_missing(method_name, *arguments, &block) connection.send(method_name, *arguments, &block) rescue Exception => e Logger.error e. Logger.error e.backtrace.inspect return nil end |
Instance Attribute Details
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
13 14 15 |
# File 'lib/artoo/drivers/driver.rb', line 13 def parent @parent end |
Instance Method Details
#connection ⇒ Object
19 20 21 |
# File 'lib/artoo/drivers/driver.rb', line 19 def connection parent.connection end |
#event_topic_name(event) ⇒ Object
35 36 37 |
# File 'lib/artoo/drivers/driver.rb', line 35 def event_topic_name(event) parent.event_topic_name(event) end |
#interval ⇒ Object
27 28 29 |
# File 'lib/artoo/drivers/driver.rb', line 27 def interval parent.interval end |
#pin ⇒ Object
23 24 25 |
# File 'lib/artoo/drivers/driver.rb', line 23 def pin parent.pin end |
#start_driver ⇒ Object
31 32 33 |
# File 'lib/artoo/drivers/driver.rb', line 31 def start_driver Logger.info "Starting driver '#{self.class.name}'..." end |