Class: Barr::Block
- Inherits:
-
Object
- Object
- Barr::Block
- Defined in:
- lib/barr/block.rb
Direct Known Subclasses
Barr::Blocks::CPU, Barr::Blocks::Clock, Barr::Blocks::HDD, Barr::Blocks::I3, Barr::Blocks::IP, Barr::Blocks::Mem, Barr::Blocks::Rhythmbox, Barr::Blocks::Temperature, Barr::Blocks::Whoami
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#bgcolor ⇒ Object
readonly
Returns the value of attribute bgcolor.
-
#fgcolor ⇒ Object
readonly
Returns the value of attribute fgcolor.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
- #<<(str) ⇒ Object
- #colors ⇒ Object
- #destroy ⇒ Object
- #destroy! ⇒ Object
- #draw ⇒ Object
-
#initialize(opts = {}) ⇒ Block
constructor
A new instance of Block.
- #reassign_deprecated_option(opts, old, new) ⇒ Object
-
#update ⇒ Object
Backwards compatiblity methods.
- #update! ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Block
Returns a new instance of Block.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/barr/block.rb', line 5 def initialize(opts = {}) reassign_deprecated_option opts, :fcolor, :fgcolor reassign_deprecated_option opts, :bcolor, :bgcolor @align = opts[:align] || :l @bgcolor = opts[:bgcolor] || '-' @fgcolor = opts[:fgcolor] || '-' @icon = opts[:icon] || '' @interval = opts[:interval] || 5 @output = '' end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
3 4 5 |
# File 'lib/barr/block.rb', line 3 def align @align end |
#bgcolor ⇒ Object (readonly)
Returns the value of attribute bgcolor.
3 4 5 |
# File 'lib/barr/block.rb', line 3 def bgcolor @bgcolor end |
#fgcolor ⇒ Object (readonly)
Returns the value of attribute fgcolor.
3 4 5 |
# File 'lib/barr/block.rb', line 3 def fgcolor @fgcolor end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
3 4 5 |
# File 'lib/barr/block.rb', line 3 def icon @icon end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
3 4 5 |
# File 'lib/barr/block.rb', line 3 def interval @interval end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
3 4 5 |
# File 'lib/barr/block.rb', line 3 def output @output end |
Instance Method Details
#<<(str) ⇒ Object
17 18 19 |
# File 'lib/barr/block.rb', line 17 def <<(str) @output << str end |
#colors ⇒ Object
21 22 23 |
# File 'lib/barr/block.rb', line 21 def colors "%{B#{bgcolor}}%{F#{fgcolor}}" end |
#destroy ⇒ Object
39 |
# File 'lib/barr/block.rb', line 39 def destroy; destroy!; end |
#destroy! ⇒ Object
29 30 |
# File 'lib/barr/block.rb', line 29 def destroy! end |
#draw ⇒ Object
25 26 27 |
# File 'lib/barr/block.rb', line 25 def draw "#{colors} #{icon} #{@output} #{reset_colors}" end |
#reassign_deprecated_option(opts, old, new) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/barr/block.rb', line 41 def reassign_deprecated_option opts, old, new if opts[new].nil? && !opts[old].nil? STDERR.puts "Warning: the '#{old}' option will soon be deprecated in favour of '#{new}'. \n Please update your script." opts[new] = opts[old] end end |
#update ⇒ Object
Backwards compatiblity methods. can’t use alias/alias_method as they don’t trickle down to subclasses
38 |
# File 'lib/barr/block.rb', line 38 def update; update!; end |
#update! ⇒ Object
32 33 |
# File 'lib/barr/block.rb', line 32 def update! end |