Method: LinuxStat::Battery.voltage_now

Defined in:
lib/linux_stat/battery.rb

.voltage_nowObject

Returns the voltage of the battery as Integer However if the info isn’t available or there’s no BAT0 in the system, this will return nil



170
171
172
173
174
175
176
# File 'lib/linux_stat/battery.rb', line 170

def voltage_now
	@@voltage_file ||= File.join(PATH, 'voltage_now'.freeze)
	@@voltage_readable ||= File.readable?(@@voltage_file)
	return nil unless @@voltage_readable

	IO.read(@@voltage_file, 16).to_f.fdiv(1000000)
end