Class: RubyHid::Store
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- RubyHid::Store
- Defined in:
- lib/ruby_hid/store.rb
Instance Attribute Summary collapse
-
#device ⇒ Object
Returns the value of attribute device.
Instance Method Summary collapse
- #init_device ⇒ Object
- #init_observers ⇒ Object
-
#initialize ⇒ Store
constructor
A new instance of Store.
Constructor Details
#initialize ⇒ Store
Returns a new instance of Store.
7 8 9 10 11 |
# File 'lib/ruby_hid/store.rb', line 7 def initialize super init_observers init_device end |
Instance Attribute Details
#device ⇒ Object
Returns the value of attribute device.
5 6 7 |
# File 'lib/ruby_hid/store.rb', line 5 def device @device end |
Instance Method Details
#init_device ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/ruby_hid/store.rb', line 13 def init_device if device.nil? self.device = Device.new( RubyHid::Device.list[0] ) end device.start_watching end |
#init_observers ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ruby_hid/store.rb', line 22 def init_observers events = Axis::EVENTS.values + Button::EVENTS.values store = self events.each do |name| send("#{name}=", 0) control = Axis.find_by_name(name) control ||= Button.find_by_name(name) control.add_event( lambda {|val| store.send("#{name}=", val)} ) end end |