Module: Vedeu::Presentation
- Included in:
- Borders::Border, Interfaces::Interface, Interfaces::Null, Null::View, Views::Char, Views::Composition, Views::Line, Views::Stream, Views::View
- Defined in:
- lib/vedeu/output/presentation/all.rb,
lib/vedeu/output/presentation/style.rb,
lib/vedeu/output/presentation/colour.rb,
lib/vedeu/output/presentation/styles.rb,
lib/vedeu/output/presentation/presentation.rb
Overview
This module allows the sharing of presentation concerns between the models: Interface, View, Line and Stream.
Defined Under Namespace
Modules: Colour, Styles Classes: Style
Instance Method Summary collapse
-
#background ⇒ Vedeu::Colours::Background
included
from Colour
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
included
from Colour
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
- #colour ⇒ Vedeu::Colours::Colour included from Colour
-
#colour=(value) ⇒ Vedeu::Colours::Colour
included
from Colour
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
-
#foreground ⇒ Vedeu::Colours::Foreground
included
from Colour
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
included
from Colour
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
-
#position? ⇒ Boolean
private
Returns a boolean indicating the model has a position attribute.
-
#render_colour ⇒ String
private
Renders the colour attributes of the receiver and yields (to then render the styles).
- #render_position ⇒ String private
-
#render_style ⇒ String
private
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
-
#style ⇒ Vedeu::Presentation::Style
included
from Styles
When the style for the model exists, return it, otherwise returns the parent style, or an empty Style.
-
#style=(value) ⇒ Vedeu::Presentation::Style
included
from Styles
Allows the setting of the style by coercing the given value into a Style.
-
#to_s ⇒ String
(also: #to_str)
Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.
Instance Method Details
#background ⇒ Vedeu::Colours::Background Originally defined in module Colour
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 Originally defined in module Colour
Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.
#colour ⇒ Vedeu::Colours::Colour Originally defined in module Colour
#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Colour
Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.
#foreground ⇒ Vedeu::Colours::Foreground Originally defined in module Colour
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 Originally defined in module Colour
Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.
#position? ⇒ Boolean (private)
Returns a boolean indicating the model has a position attribute.
24 25 26 |
# File 'lib/vedeu/output/presentation/presentation.rb', line 24 def position? self.respond_to?(:position) && position.is_a?(Vedeu::Geometry::Position) end |
#render_colour ⇒ String (private)
Renders the colour attributes of the receiver and yields (to then render the styles).
32 33 34 |
# File 'lib/vedeu/output/presentation/presentation.rb', line 32 def render_colour "#{colour}#{yield}".freeze end |
#render_position ⇒ String (private)
37 38 39 40 41 |
# File 'lib/vedeu/output/presentation/presentation.rb', line 37 def render_position return yield unless position? position.to_s { yield } end |
#render_style ⇒ String (private)
Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).
47 48 49 |
# File 'lib/vedeu/output/presentation/presentation.rb', line 47 def render_style "#{style}#{yield}".freeze end |
#style ⇒ Vedeu::Presentation::Style Originally defined in module Styles
When the style for the model exists, return it, otherwise returns the parent style, or an empty Vedeu::Presentation::Style.
#style=(value) ⇒ Vedeu::Presentation::Style Originally defined in module Styles
Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.
#to_s ⇒ String Also known as: to_str
Converts the colours and styles to escape sequences, and when the parent model has previously set the colour and style, reverts back to that for consistent formatting.
13 14 15 |
# File 'lib/vedeu/output/presentation/presentation.rb', line 13 def to_s render_position { render_colour { render_style { value } } } end |