Class: Ev3dev::Battery

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

Constant Summary collapse

PATH =
"/sys/class/power_supply"

Instance Attribute Summary

Attributes inherited from Device

#device_path

Instance Method Summary collapse

Methods inherited from Device

#method_missing

Constructor Details

#initializeBattery

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