Class: Battman::SmapiBattery
Constant Summary
Constants inherited
from Battery
Battery::CONVERSIONS
Instance Method Summary
collapse
Methods inherited from Battery
#full_energy_in, #initialize, #power_in, #remaining_charging_time_in, #remaining_energy_in, #remaining_running_time_in
Instance Method Details
#full_energy ⇒ Object
52
53
54
55
56
|
# File 'lib/battman/smapi_battery.rb', line 52
def full_energy
energy_file = File.join(path, 'last_full_capacity')
File.read(energy_file).to_f / 1000
end
|
#path ⇒ Object
6
7
8
|
# File 'lib/battman/smapi_battery.rb', line 6
def path
@path ||= "/sys/devices/platform/smapi/BAT#{@index}"
end
|
#power ⇒ Object
34
35
36
37
38
|
# File 'lib/battman/smapi_battery.rb', line 34
def power
power_file = File.join(path, 'power_avg')
File.read(power_file).to_f / 1000
end
|
#remaining_charging_time ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/battman/smapi_battery.rb', line 25
def remaining_charging_time
charging_time_file = File.join(path, 'remaining_charging_time')
file_content = File.read(charging_time_file)
raise WrongStateError if file_content == "not_charging\n"
file_content.to_i * 60
end
|
#remaining_energy ⇒ Object
46
47
48
49
50
|
# File 'lib/battman/smapi_battery.rb', line 46
def remaining_energy
energy_file = File.join(path, 'remaining_capacity')
File.read(energy_file).to_f / 1000
end
|
#remaining_percent ⇒ Object
10
11
12
13
14
|
# File 'lib/battman/smapi_battery.rb', line 10
def remaining_percent
percent_file = File.join(path, 'remaining_percent')
File.read(percent_file).to_i
end
|
#remaining_running_time ⇒ Object
16
17
18
19
20
21
22
23
|
# File 'lib/battman/smapi_battery.rb', line 16
def remaining_running_time
running_time_file = File.join(path, 'remaining_running_time')
file_content = File.read(running_time_file)
raise WrongStateError if file_content == "not_discharging\n"
file_content.to_i * 60
end
|
#state ⇒ Object
40
41
42
43
44
|
# File 'lib/battman/smapi_battery.rb', line 40
def state
state_file = File.join(path, 'state')
File.read(state_file).chomp.to_sym
end
|