Module: Colors::NamedColors

Defined in:
lib/colors/named_colors.rb

Defined Under Namespace

Classes: Mapping

Constant Summary collapse

MAPPING =
Mapping.new

Class Method Summary collapse

Class Method Details

.[](name) ⇒ Object



86
87
88
# File 'lib/colors/named_colors.rb', line 86

def self.[](name)
  MAPPING[name]
end

.nth_color?(name) ⇒ Boolean

Return whether name is an item in the color cycle.

Returns:

  • (Boolean)


91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/colors/named_colors.rb', line 91

def self.nth_color?(name)
  case name
  when String
    # do nothing
  when Symbol
    name = name.to_s
  else
    return false unless name.respond_to?(:to_str)
    name = name.to_str
  end
  name.match?(/\AC\d+\z/)
end