Class: LegoEv3::TouchSensor

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

Overview

Instance Method Summary collapse

Constructor Details

#initialize(connection, id, port) ⇒ TouchSensor

Returns a new instance of TouchSensor.



4
5
6
# File 'lib/sensors/touch.rb', line 4

def initialize(connection, id, port)
  super(connection, id, port, 'lego-ev3-touch')
end

Instance Method Details

#infoObject



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

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

#pollObject



12
13
14
# File 'lib/sensors/touch.rb', line 12

def poll
  @value = LegoEv3::Commands::LegoSensor.get_value0!(@connection, @id)
end

#pressed?Boolean

Returns:

  • (Boolean)


8
9
10
# File 'lib/sensors/touch.rb', line 8

def pressed?
  @value == 1
end