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}/port_name").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

Instance Method Details

#goObject



14
15
16
# File 'lib/ev3dev/motor.rb', line 14

def go
  run 1
end

#stopObject



18
19
20
# File 'lib/ev3dev/motor.rb', line 18

def stop
  run 0
end