Permalink
Browse files

Resolve deprecation warnings for Ruby 1.9.2

  • Loading branch information...
1 parent 1c236cc commit 96b4ab56cfbb7f9db0bcd0f232f233de3bd64596 @joshuaclayton committed Jul 23, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/palette/color.rb
View
@@ -14,7 +14,7 @@ def to_hex
def to_cterm
return "NONE" if @hex == "NONE"
- self.class.color_map.index(closest_cterm_hex)
+ cterm_of_closest_cterm_hex
end
private
@@ -31,6 +31,15 @@ def self.parse(hex)
end.upcase
end
+ def cterm_of_closest_cterm_hex
+ color_map = self.class.color_map
+ if color_map.respond_to?(:key)
+ color_map.key(closest_cterm_hex)
+ else
+ color_map.index(closest_cterm_hex)
+ end
+ end
+
def closest_cterm_hex
all_colors = self.class.color_map.values.map do |hexcode|
original_r, original_g, original_b = self.class.hex_to_decimal(@hex)

0 comments on commit 96b4ab5

Please sign in to comment.