Class: PVN::ColorFormatter
- Inherits:
-
Object
- Object
- PVN::ColorFormatter
show all
- Includes:
- Logue::Loggable
- Defined in:
- lib/pvn/util/color_formatter.rb
Instance Method Summary
collapse
Instance Method Details
#add_field(value, field) ⇒ Object
31
32
33
|
# File 'lib/pvn/util/color_formatter.rb', line 31
def add_field value, field
colorize(value, field) + pad(value, field)
end
|
#colorize(what, field) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/pvn/util/color_formatter.rb', line 17
def colorize what, field
colors = colors field
return what if colors.nil? || colors.empty?
colors.each do |col|
case col
when "bold", :bold
what = what.bright
else
what = what.color col.to_sym
end
end
what
end
|
#pad(what, field) ⇒ Object
12
13
14
15
|
# File 'lib/pvn/util/color_formatter.rb', line 12
def pad what, field
nspaces = [ width(field) - what.length, 1 ].max
" " * nspaces
end
|