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::RANGE_0_100, Constants::RANGE_0_255, Constants::RANGE_0_360, Constants::RANGE_ALPHA, Constants::RGB, Constants::RGBA, Constants::TRANSPARENT, Constants::WEBSAFE

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value) ⇒ 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

#hex?Boolean



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

def hex?;   is? HEX;  end

#hsl?Boolean



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

def hsl?;   is? HSL;  end

#hsla?Boolean



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

def hsla?;  is? HSLA; end

#inherit?Boolean



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

def inherit?; @colour == INHERIT; end

#rgb?Boolean



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

def rgb?;   is? RGB;  end

#rgba?Boolean



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

def rgba?;  is? RGBA; end

#transparent?Boolean



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

def transparent?; @colour == TRANSPARENT; end

#valid?Boolean



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

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

#websafe?Boolean



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

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