module Wirb::Colorizer::Wirb0_HighLine

Public Class Methods

color(*colors) click to toggle source
# File lib/wirb/colorizer/wirb0_highline.rb, line 16
def self.color(*colors)
  ::HighLine.color_code(*color_name(*colors))
end
color_name(*colors) click to toggle source
# File lib/wirb/colorizer/wirb0_highline.rb, line 25
def self.color_name(*colors)
  colors = colors.flatten.compact
  if colors.first == :highline # In this case, colors already use HighLine's names
    colors[1..-1]
  else
    translated_colors = colors.map do |color|
      color = color.to_s
      case color
      when "nothing"
        color = "clear"
      when %rlight_gray/
         color = color.sub("light_gray", "white")
      when %rdark_gray/
         color = color.sub("dark_gray", "light_black")  # Changed to [:bold, :black] below
      when %ryellow/
        color = color.sub("yellow", "light_yellow")     # Changed to [:bold, :yellow] below
      when %rwhite/
         color = color.sub("white", "light_white")      # Changed to [:bold, :white] below
      when %rbrown/              
        color = color.sub("brown", "yellow")
      when %rpurple/             
        color = color.sub("purple", "magenta")
      end
      color_set = [color.to_sym]
      if color_set.first.to_s =~ %r^light_(.*)/
        color_set[0] = $1.to_sym
        color_set << :bold
      end
      case color_set.first.to_s
      when %r(.*)_underline$/
        color_set[0] = [$1.to_sym]
        color_set << :underline
      when %r(.*)_background$/
        color_set[0] = [('on_'+$1).to_sym]
      end
      color_set
    end
    translated_colors.flatten
  end
end
run(s, *colors) click to toggle source
# File lib/wirb/colorizer/wirb0_highline.rb, line 20
def self.run(s, *colors)
  ::HighLine.color(s, *color_name(*colors))
end

Public Instance Methods

color(*args) click to toggle source
# File lib/wirb/colorizer/wirb0_highline.rb, line 70
def color(*args)
  self.class.color(*args)
end
color_code(*args) click to toggle source
# File lib/wirb/colorizer/wirb0_highline.rb, line 66
def color_code(*args)
  self.class.color_code(*args)
end