Method: LinuxStat::Battery.charge_full_wh

Defined in:
lib/linux_stat/battery.rb

.charge_full_whObject

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



151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/linux_stat/battery.rb', line 151

def charge_full_wh
    # voltage min design
    @@vmd_f ||= File.join(PATH, 'voltage_min_design'.freeze)
    v_m_d = File.readable?(@@vmd_f) ? IO.read(@@vmd_f).to_i : nil

    # charge full
    @@cf_f ||= File.join(PATH, 'charge_full'.freeze)
    c_f = File.readable?(@@cf_f) ? IO.read(@@cf_f).to_i : nil

    if v_m_d && c_f
      v_m_d.fdiv(1_000_000).*(c_f.fdiv(1_000_000)).round(2)
    else
      nil
    end
end