Class: BBB::Components::Nunchuck::Controls::ControlAxis
- Inherits:
-
Object
- Object
- BBB::Components::Nunchuck::Controls::ControlAxis
- Defined in:
- lib/BBB/components/nunchuck.rb
Instance Attribute Summary collapse
-
#change_callbacks ⇒ Object
Returns the value of attribute change_callbacks.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#initialize ⇒ ControlAxis
constructor
A new instance of ControlAxis.
- #on_change ⇒ Object
- #update(value) ⇒ Object
Constructor Details
#initialize ⇒ ControlAxis
Returns a new instance of ControlAxis.
137 138 139 |
# File 'lib/BBB/components/nunchuck.rb', line 137 def initialize @change_callbacks = [] end |
Instance Attribute Details
#change_callbacks ⇒ Object
Returns the value of attribute change_callbacks.
135 136 137 |
# File 'lib/BBB/components/nunchuck.rb', line 135 def change_callbacks @change_callbacks end |
#value ⇒ Object
Returns the value of attribute value.
134 135 136 |
# File 'lib/BBB/components/nunchuck.rb', line 134 def value @value end |
Instance Method Details
#on_change ⇒ Object
147 148 149 |
# File 'lib/BBB/components/nunchuck.rb', line 147 def on_change @change_callbacks.each{|c| c.call(value) } end |
#update(value) ⇒ Object
141 142 143 144 145 |
# File 'lib/BBB/components/nunchuck.rb', line 141 def update(value) old_value = self.value @value = value on_change if old_value != value end |