Class: LegoEv3::TouchSensor
- Inherits:
-
LegoSensor
- Object
- LegoSensor
- LegoEv3::TouchSensor
- Defined in:
- lib/sensors/touch.rb
Instance Attribute Summary
Attributes inherited from LegoSensor
Instance Method Summary collapse
- #info ⇒ Object
-
#initialize(connection, id, port) ⇒ TouchSensor
constructor
A new instance of TouchSensor.
- #poll ⇒ Object
- #pressed? ⇒ Boolean
Constructor Details
#initialize(connection, id, port) ⇒ TouchSensor
3 4 5 |
# File 'lib/sensors/touch.rb', line 3 def initialize(connection, id, port) super(connection, id, port, 'lego-ev3-touch') end |
Instance Method Details
#info ⇒ Object
15 16 17 18 19 20 |
# File 'lib/sensors/touch.rb', line 15 def info super.merge({ sub_type: :touch, pressed: pressed? }) end |
#poll ⇒ Object
11 12 13 |
# File 'lib/sensors/touch.rb', line 11 def poll @value = poll_value(1)[0] end |
#pressed? ⇒ Boolean
7 8 9 |
# File 'lib/sensors/touch.rb', line 7 def pressed? @value == 1 end |