Module: Vedeu::Presentation::Colour Private
- Included in:
- Vedeu::Presentation
- Defined in:
- lib/vedeu/presentation/colour.rb
Overview
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Provides colour related presentation behaviour.
Instance Method Summary collapse
-
#background ⇒ Vedeu::Colours::Background
private
When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.
-
#background=(value) ⇒ Vedeu::Colours::Background
private
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
- #colour ⇒ Vedeu::Colours::Colour private
-
#colour=(value) ⇒ Vedeu::Colours::Colour
private
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
- #colour? ⇒ Boolean private
-
#foreground ⇒ Vedeu::Colours::Foreground
private
When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.
-
#foreground=(value) ⇒ Vedeu::Colours::Foreground
private
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
- #name ⇒ NilClass|String|Symbol private
- #named_colour ⇒ Vedeu::Colours::Colour private private
- #named_colour? ⇒ Boolean private private
- #parent ⇒ NilClass|void private
- #parent_colour ⇒ Vedeu::Colours::Colour private private
- #parent_colour? ⇒ Boolean private private
-
#render_colour(&block) ⇒ String
private
private
Renders the colour attributes of the receiver and yields (to then render the styles).
Instance Method Details
#background ⇒ Vedeu::Colours::Background
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.
When the background colour for the model exists, return it, otherwise returns the parent background colour, or an empty Vedeu::Colours::Background.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vedeu/presentation/colour.rb', line 18 def background @background ||= if colour && present?(colour.background) colour.background elsif named_colour? named_colour.background elsif parent && present?(parent.background) parent.background else Vedeu::Colours::Background.new end end |
#background=(value) ⇒ Vedeu::Colours::Background
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.
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
38 39 40 41 |
# File 'lib/vedeu/presentation/colour.rb', line 38 def background=(value) @background = colour.background = value @_colour = @colour = colour end |
#colour ⇒ 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/vedeu/presentation/colour.rb', line 44 def colour @_colour ||= if colour? Vedeu::Colours::Colour.coerce(@colour) elsif parent_colour? Vedeu::Colours::Colour.coerce(parent_colour) elsif named_colour? Vedeu::Colours::Colour.coerce(named_colour) else Vedeu::Colours::Colour.new end end |
#colour=(value) ⇒ 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.
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
64 65 66 |
# File 'lib/vedeu/presentation/colour.rb', line 64 def colour=(value) @_colour = @colour = Vedeu::Colours::Colour.coerce(value) end |
#colour? ⇒ 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.
69 70 71 |
# File 'lib/vedeu/presentation/colour.rb', line 69 def colour? present?(@colour) end |
#foreground ⇒ Vedeu::Colours::Foreground
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.
When the foreground colour for the model exists, return it, otherwise returns the parent foreground colour, or an empty Vedeu::Colours::Foreground.
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/vedeu/presentation/colour.rb', line 78 def foreground @foreground ||= if colour && present?(colour.foreground) colour.foreground elsif named_colour? named_colour.foreground elsif parent && present?(parent.foreground) parent.foreground else Vedeu::Colours::Foreground.new end end |
#foreground=(value) ⇒ Vedeu::Colours::Foreground
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.
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
98 99 100 101 |
# File 'lib/vedeu/presentation/colour.rb', line 98 def foreground=(value) @foreground = colour.foreground = value @_colour = @colour = colour end |
#name ⇒ NilClass|String|Symbol
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.
109 110 111 112 113 114 115 116 117 |
# File 'lib/vedeu/presentation/colour.rb', line 109 def name if present?(@name) @name elsif parent && present?(parent.name) parent.name end end |
#named_colour ⇒ Vedeu::Colours::Colour (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.
122 123 124 |
# File 'lib/vedeu/presentation/colour.rb', line 122 def named_colour Vedeu.interfaces.by_name(name).colour end |
#named_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.
127 128 129 130 131 |
# File 'lib/vedeu/presentation/colour.rb', line 127 def named_colour? return false if is_a?(Vedeu::Interfaces::Interface) present?(name) && Vedeu.interfaces.registered?(name) end |
#parent ⇒ NilClass|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.
104 105 106 |
# File 'lib/vedeu/presentation/colour.rb', line 104 def parent present?(@parent) ? @parent : nil end |
#parent_colour ⇒ Vedeu::Colours::Colour (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.
134 135 136 |
# File 'lib/vedeu/presentation/colour.rb', line 134 def parent_colour parent.colour end |
#parent_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.
139 140 141 |
# File 'lib/vedeu/presentation/colour.rb', line 139 def parent_colour? present?(parent) && parent.respond_to?(:colour?) end |
#render_colour(&block) ⇒ String (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.
Renders the colour attributes of the receiver and yields (to then render the styles).
148 149 150 |
# File 'lib/vedeu/presentation/colour.rb', line 148 def render_colour(&block) "#{colour}#{yield}" end |