Class: Barr::Block
- Inherits:
-
Object
- Object
- Barr::Block
- Defined in:
- lib/barr/block.rb
Direct Known Subclasses
Barr::Blocks::Battery, Barr::Blocks::Bspwm, Barr::Blocks::CPU, Barr::Blocks::Clock, Barr::Blocks::Conky, Barr::Blocks::HDD, Barr::Blocks::I3, Barr::Blocks::IP, Barr::Blocks::Mem, Barr::Blocks::Processes, Barr::Blocks::Rhythmbox, Barr::Blocks::Separator, 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.
-
#manager ⇒ Object
Returns the value of attribute manager.
-
#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
- #tmp_filename ⇒ Object
-
#update ⇒ Object
Backwards compatiblity methods.
- #update! ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Block
Returns a new instance of Block.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/barr/block.rb', line 6 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 |
#manager ⇒ Object
Returns the value of attribute manager.
4 5 6 |
# File 'lib/barr/block.rb', line 4 def manager @manager 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
18 19 20 |
# File 'lib/barr/block.rb', line 18 def <<(str) @output << str end |
#colors ⇒ Object
22 23 24 |
# File 'lib/barr/block.rb', line 22 def colors "%{B#{bgcolor}}%{F#{fgcolor}}" end |
#destroy ⇒ Object
45 |
# File 'lib/barr/block.rb', line 45 def destroy; destroy!; end |
#destroy! ⇒ Object
30 31 |
# File 'lib/barr/block.rb', line 30 def destroy! end |
#draw ⇒ Object
26 27 28 |
# File 'lib/barr/block.rb', line 26 def draw "#{colors} #{icon} #{@output} #{reset_colors}" end |
#reassign_deprecated_option(opts, old, new) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/barr/block.rb', line 47 def reassign_deprecated_option opts, old, new if opts[new].nil? && !opts[old].nil? STDERR.puts "Warning: #{self.class.name}'s '#{old}' option will soon be deprecated in favour of '#{new}'. \n Please update your script." opts[new] = opts[old] end end |
#tmp_filename ⇒ Object
36 37 38 39 |
# File 'lib/barr/block.rb', line 36 def tmp_filename @tmp_filename ||= "/tmp/#{SecureRandom.uuid}-#{self.class.name.gsub(/::/, "-")}-#{SecureRandom.urlsafe_base64}" return @tmp_filename end |
#update ⇒ Object
Backwards compatiblity methods. can’t use alias/alias_method as they don’t trickle down to subclasses
44 |
# File 'lib/barr/block.rb', line 44 def update; update!; end |
#update! ⇒ Object
33 34 |
# File 'lib/barr/block.rb', line 33 def update! end |