Sha256: 288a116f28b5699ba33f7f24b02fad1b25957f0f08f53cc13ce9018dccd81d0a

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

module Artoo
  module Drivers
    # 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.
    class Driver
      include Celluloid
      include Celluloid::Notifications
      
      attr_reader :parent

      def initialize(params={})
        @parent = params[:parent]
      end

      def connection
        parent.connection
      end

      def pin
        parent.pin
      end

      def interval
        parent.interval
      end

      def start_driver
        Logger.info "Starting driver '#{self.class.name}'..."
      end

      def event_topic_name(event)
        parent.event_topic_name(event)
      end

      def method_missing(method_name, *arguments, &block)
        connection.send(method_name, *arguments, &block)
      rescue Exception => e
        Logger.error e.message
        Logger.error e.backtrace.inspect
        return nil
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
artoo-0.4.0 lib/artoo/drivers/driver.rb
artoo-0.3.0 lib/artoo/drivers/driver.rb
artoo-0.2.0 lib/artoo/drivers/driver.rb
artoo-0.1.3 lib/artoo/drivers/driver.rb
artoo-0.1.2 lib/artoo/drivers/driver.rb
artoo-0.1.1 lib/artoo/drivers/driver.rb
artoo-0.1.0 lib/artoo/drivers/driver.rb