Class: Batt::Formatter::Tmux

Inherits:
Object
  • Object
show all
Defined in:
lib/batt/formatter/tmux.rb

Class Method Summary collapse

Class Method Details

.bg_color(color) ⇒ Object



20
21
22
23
24
# File 'lib/batt/formatter/tmux.rb', line 20

def bg_color(color)
  return nil unless color

  "bg=#{ color }"
end

.fg_color(color) ⇒ Object



26
27
28
29
30
# File 'lib/batt/formatter/tmux.rb', line 26

def fg_color(color)
  return nil unless color

  "fg=#{ color }"
end

.format(string, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/batt/formatter/tmux.rb', line 7

def format(string, options={})
  fg = options[:fg]
  bg = options[:bg]

  color_string = [ bg_color(bg), fg_color(fg) ].compact.join(',')

  if color_string.length > 0
    "#[#{ color_string }]#{ string }#[default]"
  else
    string
  end
end