Class: Vedeu::Coercers::Colour Private
- 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
Instance Method Summary collapse
- #background? ⇒ Boolean private private
- #coerce ⇒ Vedeu::Colours::Colour private
- #colour_attributes ⇒ Hash private private
- #foreground? ⇒ Boolean private private
- #klass ⇒ Class private private
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.
46 47 48 |
# File 'lib/vedeu/coercers/colour.rb', line 46 def background? value.is_a?(Vedeu::Colours::Background) end |
#coerce ⇒ Vedeu::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.
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_attributes ⇒ Hash (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.
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.
51 52 53 |
# File 'lib/vedeu/coercers/colour.rb', line 51 def foreground? value.is_a?(Vedeu::Colours::Foreground) end |