class Barr::Block

Attributes

align[R]
bgcolor[R]
fgcolor[R]
icon[R]
interval[R]
manager[RW]
output[R]

Public Class Methods

new(opts = {}) click to toggle source
# 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

Public Instance Methods

<<(str) click to toggle source
# File lib/barr/block.rb, line 18
def <<(str)
  @output << str
end
colors() click to toggle source
# File lib/barr/block.rb, line 22
def colors
  "%{B#{bgcolor}}%{F#{fgcolor}}"
end
destroy() click to toggle source
# File lib/barr/block.rb, line 45
def destroy; destroy!; end
destroy!() click to toggle source
# File lib/barr/block.rb, line 30
def destroy!
end
draw() click to toggle source
# File lib/barr/block.rb, line 26
def draw
  "#{colors} #{icon} #{@output} #{reset_colors}"
end
reassign_deprecated_option(opts, old, new) click to toggle source
# 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() click to toggle source
# 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() click to toggle source

Backwards compatiblity methods. can’t use alias/alias_method as they don’t trickle down to subclasses

# File lib/barr/block.rb, line 44
def update; update!; end
update!() click to toggle source
# File lib/barr/block.rb, line 33
def update!
end

Private Instance Methods

invert_colors() click to toggle source
# File lib/barr/block.rb, line 60
def invert_colors
  '%{R}'
end
reset_colors() click to toggle source
# File lib/barr/block.rb, line 56
def reset_colors
  '%{F-}%{B-}'
end