Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Resolve deprecation warnings for Ruby 1.9.2

  • Loading branch information...
commit 96b4ab56cfbb7f9db0bcd0f232f233de3bd64596 1 parent 1c236cc
Joshua Clayton authored

Showing 1 changed file with 10 additions and 1 deletion. Show diff stats Hide diff stats

  1. +10 1 lib/palette/color.rb
11 lib/palette/color.rb
@@ -14,7 +14,7 @@ def to_hex
14 14
15 15 def to_cterm
16 16 return "NONE" if @hex == "NONE"
17   - self.class.color_map.index(closest_cterm_hex)
  17 + cterm_of_closest_cterm_hex
18 18 end
19 19
20 20 private
@@ -31,6 +31,15 @@ def self.parse(hex)
31 31 end.upcase
32 32 end
33 33
  34 + def cterm_of_closest_cterm_hex
  35 + color_map = self.class.color_map
  36 + if color_map.respond_to?(:key)
  37 + color_map.key(closest_cterm_hex)
  38 + else
  39 + color_map.index(closest_cterm_hex)
  40 + end
  41 + end
  42 +
34 43 def closest_cterm_hex
35 44 all_colors = self.class.color_map.values.map do |hexcode|
36 45 original_r, original_g, original_b = self.class.hex_to_decimal(@hex)

0 comments on commit 96b4ab5

Please sign in to comment.
Something went wrong with that request. Please try again.