Module: Vedeu::Presentation Private
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.
This module allows the sharing of presentation concerns between the models: Interface, Line and Stream.
Instance Method Summary collapse
-
#colour ⇒ Colour
private
Returns a new Colour instance.
-
#parent_colour ⇒ String
private
private
Returns the parent colour as an escape sequence if set.
-
#parent_style ⇒ String
private
private
Returns the parent style as an escape sequence if set.
-
#render_colour(&block) ⇒ String
private
private
Renders the colour attributes of the receiver, yields (to then render the the styles) and once returned, attempts to set the colours back to the those of the receiver’s parent.
-
#render_style(&block) ⇒ String
private
private
Renders the style attributes of the receiver, yields (to then render the next model, or finally, the content) and once returned, attempts to set the colours back to those of the receiver’s parent.
-
#style ⇒ Style
private
Returns a new Style instance.
-
#to_s ⇒ String
private
Converts the colours and styles to escape sequences, and if the parent model has previously set the colour and style, reverts back to that for consistent formatting.
-
#view_attributes ⇒ Hash
private
Returns the colour and style attributes of the receiving class.
Instance Method Details
#colour ⇒ 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 a new Colour instance.
22 23 24 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 22 def colour @colour ||= Colour.new(attributes[:colour]) end |
#parent_colour ⇒ 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.
Returns the parent colour as an escape sequence if set.
72 73 74 75 76 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 72 def parent_colour return '' if parent.nil? Colour.new(parent[:colour]).to_s end |
#parent_style ⇒ 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.
Returns the parent style as an escape sequence if set.
81 82 83 84 85 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 81 def parent_style return '' if parent.nil? Style.new(parent[:style]).to_s 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, yields (to then render the the styles) and once returned, attempts to set the colours back to the those of the receiver’s parent.
54 55 56 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 54 def render_colour(&block) [ colour.to_s, yield, parent_colour ].join end |
#render_style(&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 style attributes of the receiver, yields (to then render the next model, or finally, the content) and once returned, attempts to set the colours back to those of the receiver’s parent.
64 65 66 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 64 def render_style(&block) [ style.to_s, yield, parent_style ].join end |
#style ⇒ Style
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 new Style instance.
29 30 31 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 29 def style @style ||= Style.new(attributes[:style]) end |
#to_s ⇒ String
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 the colours and styles to escape sequences, and if the parent model has previously set the colour and style, reverts back to that for consistent formatting.
38 39 40 41 42 43 44 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 38 def to_s render_colour do render_style do data end end end |
#view_attributes ⇒ Hash
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 colour and style attributes of the receiving class.
12 13 14 15 16 17 |
# File 'lib/vedeu/models/attributes/presentation.rb', line 12 def view_attributes { colour: attributes[:colour], style: attributes[:style], } end |