Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resolve deprecation warnings for Ruby 1.9.2

  • Loading branch information...
commit 96b4ab56cfbb7f9db0bcd0f232f233de3bd64596 1 parent 1c236cc
@joshuaclayton authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 lib/palette/color.rb
View
11 lib/palette/color.rb
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.