Class: CssColour::Validator

Inherits:
Object
  • Object
show all
Includes:
Constants
Defined in:
lib/css-colour.rb

Constant Summary

Constants included from Constants

Constants::HEX, Constants::HSL, Constants::HSLA, Constants::INHERIT, Constants::NO_SPACE, Constants::RANGE_0_100, Constants::RANGE_0_255, Constants::RANGE_0_360, Constants::RANGE_ALPHA, Constants::RGB, Constants::RGBA, Constants::SPACE, Constants::WEBSAFE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ Validator

Returns a new instance of Validator.



10
# File 'lib/css-colour.rb', line 10

def initialize(value); self.colour = value; end

Instance Attribute Details

#colourObject

Returns the value of attribute colour.



8
9
10
# File 'lib/css-colour.rb', line 8

def colour
  @colour
end

Instance Method Details

#clean(value) ⇒ Object



13
# File 'lib/css-colour.rb', line 13

def clean(value); value.downcase.gsub(SPACE, NO_SPACE); end

#hex?Boolean

Returns:

  • (Boolean)


19
# File 'lib/css-colour.rb', line 19

def hex?;   is? HEX;  end

#hsl?Boolean

Returns:

  • (Boolean)


20
# File 'lib/css-colour.rb', line 20

def hsl?;   is? HSL;  end

#hsla?Boolean

Returns:

  • (Boolean)


21
# File 'lib/css-colour.rb', line 21

def hsla?;  is? HSLA; end

#inherit?Boolean

Returns:

  • (Boolean)


17
# File 'lib/css-colour.rb', line 17

def inherit?; @colour == INHERIT; end

#rgb?Boolean

Returns:

  • (Boolean)


22
# File 'lib/css-colour.rb', line 22

def rgb?;   is? RGB;  end

#rgba?Boolean

Returns:

  • (Boolean)


23
# File 'lib/css-colour.rb', line 23

def rgba?;  is? RGBA; end

#valid?Boolean

Returns:

  • (Boolean)


15
# File 'lib/css-colour.rb', line 15

def valid?; inherit? or websafe? or hex? or rgb? or rgba? or hsl? or hsla?; end

#websafe?Boolean

Returns:

  • (Boolean)


18
# File 'lib/css-colour.rb', line 18

def websafe?; WEBSAFE.include? @colour; end