Class: Ev3dev::Battery
Constant Summary collapse
- PATH =
"/sys/class/power_supply"
Instance Attribute Summary
Attributes inherited from Device
Instance Method Summary collapse
-
#initialize ⇒ Battery
constructor
A new instance of Battery.
Methods inherited from Device
Constructor Details
#initialize ⇒ Battery
Returns a new instance of Battery.
5 6 7 8 9 10 11 12 13 |
# File 'lib/ev3dev/battery.rb', line 5 def initialize Dir.glob("#{PATH}/*").each do |path| if File.exist?("#{path}/voltage_now") super path return end end raise "couldn't find battery attributes" end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ev3dev::Device