module RussianColorNamesRuby

Constants

VERSION

Public Class Methods

normalized_color(symbols_from_input) click to toggle source
# File lib/russian_color_names_ruby.rb, line 35
def normalized_color(symbols_from_input)
  symbols_from_input.gsub!('#','')
  if !!(symbols_from_input =~ HEX_COLOR_REGEX)

    current_pattern =
    case symbols_from_input.length
    when 3
      /./
    when 6
      /../
    end
    prepared_array = symbols_from_input.scan current_pattern

    prepared_array = prepared_array.map do |d|
      symbols =
      case symbols_from_input.length
      when 3
        d * 2
      when 6
        d
      end
      symbols
    end

    color = prepared_array.join
    color = color.insert(0, '#')
    return color.downcase
  end
end
show_color_name(symbols_from_input) click to toggle source
# File lib/russian_color_names_ruby.rb, line 23
def show_color_name(symbols_from_input)
  symbols_from_input = normalized_color(symbols_from_input)
  if !!(symbols_from_input =~ SIX_DIGIT_HEX_COLOR_REGEX)
    color = @@data.select{|key, hash| key[:hex] == symbols_from_input }
    begin
      color[0][:name]
    rescue
      nil
    end
  end
end
show_random() click to toggle source
# File lib/russian_color_names_ruby.rb, line 18
def show_random
 color = @@data.sample
 color = color[:name]
end
show_raw_data() click to toggle source
# File lib/russian_color_names_ruby.rb, line 14
def show_raw_data
  return @@data
end