Class: Vedeu::Coercers::Colour Private

Inherits:
Coercer
  • Object
show all
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

Attributes inherited from Coercer

#attributes, #value

Instance Method Summary collapse

Methods inherited from Coercer

#child_klass, coerce, #coerced?, #incoercible!, #initialize

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Constructor Details

This class inherits a constructor from Vedeu::Coercers::Coercer

Instance Method Details

#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.

Returns:



46
47
48
# File 'lib/vedeu/coercers/colour.rb', line 46

def background?
  value.is_a?(Vedeu::Colours::Background)
end

#coerceVedeu::Colours::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.

Returns:

Raises:

  • (Vedeu::Error::Fatal)

    When Vedeu does not understand that which the client application is attempting to achieve.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/vedeu/coercers/colour.rb', line 16

def coerce
  if coerced?
    value

  elsif absent?(value)
    klass.new

  elsif background?
    klass.new(background: value)

  elsif foreground?
    klass.new(foreground: value)

  elsif hash?(value)
    klass.new(colour_attributes)

  else
    incoercible!

  end
end

#colour_attributesHash (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.

Returns:

  • (Hash)


41
42
43
# File 'lib/vedeu/coercers/colour.rb', line 41

def colour_attributes
  Vedeu::Coercers::ColourAttributes.coerce(value)
end

#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.

Returns:



51
52
53
# File 'lib/vedeu/coercers/colour.rb', line 51

def foreground?
  value.is_a?(Vedeu::Colours::Foreground)
end

#klassClass (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.

Returns:

  • (Class)


56
57
58
# File 'lib/vedeu/coercers/colour.rb', line 56

def klass
  Vedeu::Colours::Colour
end