Method: Rib::Color.find_color

Defined in:
lib/rib/more/color.rb

.find_color(colors, value) ⇒ Object



87
88
89
90
91
92
93
94
# File 'lib/rib/more/color.rb', line 87

def find_color colors, value
  (colors.sort{ |(k1, _), (k2, _)|
    # Class <=> Class
    if    k1 < k2 then -1
    elsif k1 > k2 then  1
    else                0
    end}.find{ |(klass, _)| value.kind_of?(klass) } || []).last
end