Class: Vedeu::Colours::Validator Private
- Inherits:
-
Object
- Object
- Vedeu::Colours::Validator
- Includes:
- Vedeu::Common
- Defined in:
- lib/vedeu/colours/validator.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Validates the value as a valid colour string in HTML/CSS format, e.g. ‘#123456’.
Instance Attribute Summary collapse
- #value ⇒ String readonly protected private
Class Method Summary collapse
- .valid?(value) ⇒ Boolean private
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether a variable is nil or empty.
- #background? ⇒ Boolean private private
-
#become(klass, attributes) ⇒ Class
included
from Vedeu::Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value is a Boolean.
- #colour? ⇒ Boolean private private
-
#escape?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.).
-
#falsy?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value should be considered false.
- #foreground? ⇒ Boolean private private
-
#hash?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value is a Hash.
- #initialize(value) ⇒ Vedeu::Colours::Validator constructor private
-
#line_model? ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating the model is a Views::Line.
-
#named? ⇒ Boolean
private
Returns a boolean indicating whether the colour provided is a valid named colour.
-
#numbered? ⇒ Boolean
private
Returns a boolean indicating whether the value is within the range of valid terminal numbered colours.
-
#numeric?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#present?(variable) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#rgb? ⇒ Boolean
private
Returns a boolean indicated whether the colour is a valid HTML/CSS colour.
-
#snake_case(klass) ⇒ String
included
from Vedeu::Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#truthy?(value) ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating whether the value should be considered true.
- #valid? ⇒ Boolean private
-
#view_model? ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating the model is a Views::View.
Constructor Details
#initialize(value) ⇒ Vedeu::Colours::Validator
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/vedeu/colours/validator.rb', line 24 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ String (readonly, protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
63 64 65 |
# File 'lib/vedeu/colours/validator.rb', line 63 def value @value end |
Class Method Details
.valid?(value) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
18 19 20 |
# File 'lib/vedeu/colours/validator.rb', line 18 def self.valid?(value) new(value).valid? end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
#background? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
68 69 70 |
# File 'lib/vedeu/colours/validator.rb', line 68 def background? value.is_a?(Vedeu::Colours::Background) end |
#become(klass, attributes) ⇒ Class Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts one class into another.
#boolean(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the value was a boolean.
#boolean?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Boolean.
#colour? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 |
# File 'lib/vedeu/colours/validator.rb', line 73 def colour? value.is_a?(Vedeu::Colours::Colour) end |
#escape?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
#falsy?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered false.
#foreground? ⇒ Boolean (private)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
78 79 80 |
# File 'lib/vedeu/colours/validator.rb', line 78 def foreground? value.is_a?(Vedeu::Colours::Foreground) end |
#hash?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Hash.
#line_model? ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Line.
#named? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the colour provided is a valid named colour.
32 33 34 |
# File 'lib/vedeu/colours/validator.rb', line 32 def named? Vedeu.esc.valid_name?(value) end |
#numbered? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is within the range of valid terminal numbered colours.
40 41 42 |
# File 'lib/vedeu/colours/validator.rb', line 40 def numbered? numeric?(value) && value >= 0 && value <= 255 end |
#numeric?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
#present?(variable) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
#rgb? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicated whether the colour is a valid HTML/CSS colour.
48 49 50 51 52 |
# File 'lib/vedeu/colours/validator.rb', line 48 def rgb? return true if value =~ /^#([A-Fa-f0-9]{6})$/ false end |
#snake_case(klass) ⇒ String Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
#stream_model? ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::Stream.
#string?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value is a Fixnum.
#truthy?(value) ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether the value should be considered true.
#valid? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
55 56 57 |
# File 'lib/vedeu/colours/validator.rb', line 55 def valid? background? || colour? || foreground? || rgb? || named? || numbered? end |
#view_model? ⇒ Boolean Originally defined in module Vedeu::Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating the model is a Views::View.