Class: Barr::Blocks::Battery
- Inherits:
-
Barr::Block
- Object
- Barr::Block
- Barr::Blocks::Battery
- Defined in:
- lib/barr/blocks/battery.rb
Instance Attribute Summary collapse
-
#show_remaining ⇒ Object
readonly
Returns the value of attribute show_remaining.
Attributes inherited from Barr::Block
#align, #bgcolor, #fgcolor, #icon, #interval, #manager, #output
Instance Method Summary collapse
- #battery_no_remaining ⇒ Object
- #battery_remaining ⇒ Object
-
#initialize(opts = {}) ⇒ Battery
constructor
A new instance of Battery.
- #update! ⇒ Object
Methods inherited from Barr::Block
#<<, #colors, #destroy, #destroy!, #draw, #reassign_deprecated_option, #tmp_filename, #update
Constructor Details
#initialize(opts = {}) ⇒ Battery
Returns a new instance of Battery.
9 10 11 12 |
# File 'lib/barr/blocks/battery.rb', line 9 def initialize opts={} super @show_remaining = opts[:show_remaining].nil? ? true : opts[:show_remaining] end |
Instance Attribute Details
#show_remaining ⇒ Object (readonly)
Returns the value of attribute show_remaining.
7 8 9 |
# File 'lib/barr/blocks/battery.rb', line 7 def show_remaining @show_remaining end |
Instance Method Details
#battery_no_remaining ⇒ Object
26 27 28 |
# File 'lib/barr/blocks/battery.rb', line 26 def battery_no_remaining `acpi | cut -d ',' -f 2`.chomp end |
#battery_remaining ⇒ Object
22 23 24 |
# File 'lib/barr/blocks/battery.rb', line 22 def battery_remaining `acpi | cut -d ',' -f 2-3`.chomp end |
#update! ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/barr/blocks/battery.rb', line 14 def update! if @show_remaining == true @output = battery_remaining else @output = battery_no_remaining end end |