Class: Ev3dev::Sensor

Inherits:
Device
  • Object
show all
Defined in:
lib/ev3dev/sensor.rb

Constant Summary collapse

PATH =
"/sys/class/lego-sensor"

Instance Attribute Summary

Attributes inherited from Device

#device_path

Instance Method Summary collapse

Methods inherited from Device

#method_missing

Constructor Details

#initialize(port) ⇒ Sensor

Returns a new instance of Sensor.



5
6
7
8
9
10
11
12
# File 'lib/ev3dev/sensor.rb', line 5

def initialize(port)
  Dir.glob("#{PATH}/sensor*").each do |path|
    if IO.read("#{path}/port_name").strip == "in#{port.to_s}"
      super path
      return
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ev3dev::Device