Class: Vedeu::Coercers::Colour Private
- Inherits:
-
Object
- Object
- Vedeu::Coercers::Colour
- Includes:
- Vedeu::Common
- Defined in:
- lib/vedeu/coercers/colour.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.
Converts a given value into a Vedeu::Colours::Colour if possible.
Instance Attribute Summary collapse
- #value ⇒ void readonly protected private
Class Method Summary collapse
- .coerce(value) ⇒ void 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.
- #coerce ⇒ void private
- #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::Coercers::Colour constructor private
-
#line_model? ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating the model is a Views::Line.
-
#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.
-
#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.
-
#view_model? ⇒ Boolean
included
from Vedeu::Common
private
Returns a boolean indicating the model is a Views::View.
Constructor Details
#initialize(value) ⇒ Vedeu::Coercers::Colour
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/coercers/colour.rb', line 24 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ void (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.
This method returns an undefined value.
57 58 59 |
# File 'lib/vedeu/coercers/colour.rb', line 57 def value @value end |
Class Method Details
.coerce(value) ⇒ void
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.
This method returns an undefined value.
18 19 20 |
# File 'lib/vedeu/coercers/colour.rb', line 18 def self.coerce(value) new(value).coerce 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.
62 63 64 |
# File 'lib/vedeu/coercers/colour.rb', line 62 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.
#coerce ⇒ void
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.
This method returns an undefined value.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/vedeu/coercers/colour.rb', line 30 def coerce if absent?(value) Vedeu::Colours::Colour.new elsif background? Vedeu::Colours::Colour.new(background: value) elsif colour? value elsif foreground? Vedeu::Colours::Colour.new(foreground: value) elsif hash?(value) attributes = Vedeu::Coercers::ColourAttributes.coerce(value) Vedeu::Colours::Colour.new(attributes) else fail Vedeu::Error::Fatal, 'Vedeu cannot coerce this colour.' end end |
#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.
67 68 69 |
# File 'lib/vedeu/coercers/colour.rb', line 67 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.
72 73 74 |
# File 'lib/vedeu/coercers/colour.rb', line 72 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.
#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.
#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.
#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.