Skip to content

Commit

Permalink
Temporary debugging stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rleber committed Jun 27, 2011
1 parent c90fbe7 commit 5770ec8
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions lib/highline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,13 @@ def choose( *items, &details )
#
def self.color( string, *colors )
return string unless self.use_color?

colors.map! do |c|
color_code(*colors) + string + CLEAR
end

# In case you just want the color code, without the embedding and the CLEAR
def self.color_code(*colors)
original_colors = colors
colors = colors.map do |c|
if self.using_color_scheme? and self.color_scheme.include? c
self.color_scheme[c]
elsif c.is_a? Symbol
Expand All @@ -352,7 +357,14 @@ def self.color( string, *colors )
c
end
end
"#{colors.flatten.join}#{string}#{CLEAR}"
res = colors.flatten.join
$stderr.puts "HighLine.color_code(#{original_colors.map{|color| color.inspect}.join(',')}) => #{res.inspect}"
res
end

# Works as an instance method, same as the class method
def color_code(*colors)
self.class.color_code(*colors)
end

# Works as an instance method, same as the class method
Expand Down

0 comments on commit 5770ec8

Please sign in to comment.