Class: Ev3dev::Motor
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
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
#go ⇒ Object
14
15
16
|
# File 'lib/ev3dev/motor.rb', line 14
def go
run 1
end
|
#stop ⇒ Object
18
19
20
|
# File 'lib/ev3dev/motor.rb', line 18
def stop
run 0
end
|