class SoPerf::ColorHelper
Public Class Methods
color(str, color)
click to toggle source
# File lib/soperf/color_helper.rb, line 39 def self.color(str, color) if @@use_color case color when :cyan str.cyan when :green str.green when :red str.red when :yellow str.yellow when :magenta str.magenta when :light_blue str.light_blue when :light_green str.light_green when :light_red str.light_red when :light_yellow str.light_yellow else str end else str end end
colorize(str, color)
click to toggle source
# File lib/soperf/color_helper.rb, line 28 def self.colorize(str, color) if @@use_color str.gsub( TICK_CHAR, ColorHelper.color(TICK_CHAR, color)).gsub( TICK_ON_LINE_CHAR, ColorHelper.color(TICK_ON_LINE_CHAR, color)).gsub( TICK_ON_LINE_START_CHAR, ColorHelper.color(TICK_ON_LINE_START_CHAR, color)).gsub( TICK_ON_LINE_END_CHAR, ColorHelper.color(TICK_ON_LINE_END_CHAR, color)).gsub( SINGLE_SPACE_LINE, ColorHelper.color(SINGLE_SPACE_LINE, color)) end end
pick_a_color()
click to toggle source
# File lib/soperf/color_helper.rb, line 20 def self.pick_a_color colors = [:cyan, :green, :red, :yellow, :magenta, :light_blue, :light_green, :light_red, :light_yellow] @@color_index ||= -1 @@color_index += 1 @@color_index =0 if @@color_index>colors.length-1 colors[@@color_index] end
reset_color_index()
click to toggle source
# File lib/soperf/color_helper.rb, line 16 def self.reset_color_index @@color_index = -1 end
use_color(bool=true)
click to toggle source
# File lib/soperf/color_helper.rb, line 8 def self.use_color(bool=true) @@use_color = bool end
use_color?()
click to toggle source
# File lib/soperf/color_helper.rb, line 12 def self.use_color? @@use_color end