Created
September 4, 2008 16:34
-
-
Save atduskgreg/8802 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module HardwareBase | |
def self.register_device_type mod, sym | |
@@device_registrations ||= {} | |
@@device_registrations[sym] = mod | |
end | |
end | |
module Servo | |
include HardwareBase | |
HardwareBase.register_device_type self, :servo | |
def output_pin_setup(num,opts) | |
#...do stuff... | |
end | |
end | |
module I2C | |
include HardwareBase | |
HardwareBase.register_device_type self, :i2c | |
def output_pin_setup(num,opts) | |
#...do stuff... | |
end | |
end | |
class ArduinoSketch | |
include Servo | |
include I2C | |
def initialize | |
puts @@device_registrations.inspect | |
end | |
end | |
ArduinoSketch.new#.device_registrations.inspect |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment