Class: Ev3dev::Motor

Inherits:
Device show all
Defined in:
lib/ev3dev/motor.rb

Constant Summary collapse

PATH =
"/sys/class/tacho-motor"

Instance Attribute Summary

Attributes inherited from Device

#device_path

Instance Method Summary collapse

Methods inherited from Device

#method_missing

Constructor Details

#initialize(port) ⇒ Motor

Returns a new instance of Motor.



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

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

Dynamic Method Handling

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