Class: LegoEv3::TouchSensor

Inherits:
LegoSensor show all
Defined in:
lib/sensors/touch.rb

Instance Attribute Summary

Attributes inherited from LegoSensor

#value

Instance Method Summary collapse

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

#infoObject



15
16
17
18
19
20
# File 'lib/sensors/touch.rb', line 15

def info
  super.merge({
    sub_type: :touch,
    pressed: pressed?
  })
end

#pollObject



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