class Juden::Battery
Attributes
percentage[R]
state[R]
Public Class Methods
new()
click to toggle source
# File lib/juden/battery.rb, line 8 def initialize @percentage = `upower -i $(upower -e | grep BAT) | grep percentage`.split.last @state = `upower -i $(upower -e | grep BAT) | grep state`.split.last end
Public Instance Methods
discharging?()
click to toggle source
@return [Boolean]
# File lib/juden/battery.rb, line 24 def discharging? state == 'discharging' end
low_battery?()
click to toggle source
@return [Boolean]
# File lib/juden/battery.rb, line 14 def low_battery? percentage.to_i < config.threshold_percentage end
percentage_num()
click to toggle source
@return [Integer]
# File lib/juden/battery.rb, line 19 def percentage_num percentage.split('%').first.to_i end
Private Instance Methods
config()
click to toggle source
@return [Config]
# File lib/juden/battery.rb, line 31 def config Config.instance end