Class: FeduxOrgStdlib::Colors::HtmlColor

Inherits:
Object
  • Object
show all
Defined in:
lib/fedux_org_stdlib/colors/html_color.rb

Overview

HTML color

Helps you to check if given string is a valid html color

Instance Method Summary collapse

Constructor Details

#initialize(color) ⇒ HtmlColor

Returns a new instance of HtmlColor.

Parameters:

  • color (String)

    string in the html color format



10
11
12
13
# File 'lib/fedux_org_stdlib/colors/html_color.rb', line 10

def initialize(color)
  @color           = color
  @validator_regex = /^#[a-f0-9]{6}$/
end

Instance Method Details

#valid?true, false

Is color valid?

Returns:

  • (true, false)

    color string is valid



17
18
19
20
21
# File 'lib/fedux_org_stdlib/colors/html_color.rb', line 17

def valid?
  # rubocop:disable Style/CaseEquality
  @validator_regex === @color
  # rubocop:enable Style/CaseEquality
end