Module: Vedeu::Presentation::Colour Private
- Includes:
- Parent
- Included in:
- Borders::Border, Cells::Empty, Interfaces::Interface, Interfaces::Null, Output::Write, Views::Composition, Views::Line, Views::Stream, Views::View
- 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.
-
#interface ⇒ Vedeu::Interfaces::Interface
private
private
Returns the named interface/view from the interfaces repository.
- #name ⇒ NilClass|String|Symbol private
- #named_colour ⇒ Vedeu::Colours::Colour private private
- #named_colour? ⇒ Boolean private 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).
Methods included from Parent
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.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vedeu/presentation/colour.rb', line 20 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.
40 41 42 43 |
# File 'lib/vedeu/presentation/colour.rb', line 40 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.
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/vedeu/presentation/colour.rb', line 46 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.
66 67 68 |
# File 'lib/vedeu/presentation/colour.rb', line 66 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.
71 72 73 |
# File 'lib/vedeu/presentation/colour.rb', line 71 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.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/vedeu/presentation/colour.rb', line 80 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.
100 101 102 103 |
# File 'lib/vedeu/presentation/colour.rb', line 100 def foreground=(value) @foreground = colour.foreground = value @_colour = @colour = colour end |
#interface ⇒ Vedeu::Interfaces::Interface (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 the named interface/view from the interfaces repository.
119 120 121 |
# File 'lib/vedeu/presentation/colour.rb', line 119 def interface Vedeu.interfaces.by_name(name) 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.
106 107 108 109 110 111 112 113 114 |
# File 'lib/vedeu/presentation/colour.rb', line 106 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.
124 125 126 |
# File 'lib/vedeu/presentation/colour.rb', line 124 def named_colour interface.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.
129 130 131 132 133 |
# File 'lib/vedeu/presentation/colour.rb', line 129 def named_colour? return false if is_a?(Vedeu::Interfaces::Interface) present?(name) && Vedeu.interfaces.registered?(name) 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.
136 137 138 |
# File 'lib/vedeu/presentation/colour.rb', line 136 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.
141 142 143 |
# File 'lib/vedeu/presentation/colour.rb', line 141 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).
150 151 152 |
# File 'lib/vedeu/presentation/colour.rb', line 150 def render_colour(&block) "#{colour}#{yield}" end |