Module: Vedeu::Presentation
- Included in:
- Char, Composition, Interface, Line, Stream
- Defined in:
- lib/vedeu/output/presentation.rb
Overview
This module allows the sharing of presentation concerns between the models: Interface, Line and Stream.
Instance Method Summary collapse
- #background ⇒ Vedeu::Background|NilClass
- #colour ⇒ Vedeu::Colour
- #colour=(value) ⇒ Vedeu::Colour
- #foreground ⇒ Vedeu::Foreground|NilClass
- #parent_background ⇒ Vedeu::Background|NilClass
- #parent_colour ⇒ String|NilClass private
- #parent_foreground ⇒ Vedeu::Foreground|NilClass
- #parent_style ⇒ String|NilClass private
- #render_border ⇒ String private
-
#render_colour ⇒ String
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_position ⇒ String private
-
#render_style ⇒ String
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 style back to that of the receiver’s parent.
- #style ⇒ Vedeu::Style
- #style=(value) ⇒ Vedeu::Style
-
#to_s ⇒ String
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.
Instance Method Details
#background ⇒ Vedeu::Background|NilClass
9 10 11 12 13 |
# File 'lib/vedeu/output/presentation.rb', line 9 def background if colour colour.background end end |
#colour ⇒ Vedeu::Colour
37 38 39 |
# File 'lib/vedeu/output/presentation.rb', line 37 def colour Vedeu::Colour.coerce(@colour) end |
#colour=(value) ⇒ Vedeu::Colour
42 43 44 |
# File 'lib/vedeu/output/presentation.rb', line 42 def colour=(value) @colour = Vedeu::Colour.coerce(value) end |
#foreground ⇒ Vedeu::Foreground|NilClass
16 17 18 19 20 |
# File 'lib/vedeu/output/presentation.rb', line 16 def foreground if colour colour.foreground end end |
#parent_background ⇒ Vedeu::Background|NilClass
23 24 25 26 27 |
# File 'lib/vedeu/output/presentation.rb', line 23 def parent_background if parent_colour parent_colour.background end end |
#parent_colour ⇒ String|NilClass (private)
68 69 70 |
# File 'lib/vedeu/output/presentation.rb', line 68 def parent_colour parent.colour if parent end |
#parent_foreground ⇒ Vedeu::Foreground|NilClass
30 31 32 33 34 |
# File 'lib/vedeu/output/presentation.rb', line 30 def parent_foreground if parent_colour parent_colour.foreground end end |
#parent_style ⇒ String|NilClass (private)
73 74 75 |
# File 'lib/vedeu/output/presentation.rb', line 73 def parent_style parent.style if parent end |
#render_border ⇒ String (private)
78 79 80 81 82 83 84 85 86 |
# File 'lib/vedeu/output/presentation.rb', line 78 def render_border if self.respond_to?(:border) && !border.nil? Esc.border { yield } else yield end end |
#render_colour ⇒ String (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.
93 94 95 96 97 98 99 |
# File 'lib/vedeu/output/presentation.rb', line 93 def render_colour [ colour, yield, parent_colour ].join end |
#render_position ⇒ String (private)
102 103 104 105 106 107 108 109 110 |
# File 'lib/vedeu/output/presentation.rb', line 102 def render_position if self.respond_to?(:position) && position.is_a?(Position) position.to_s { yield } else yield end end |
#render_style ⇒ String (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 style back to that of the receiver’s parent.
117 118 119 120 121 122 123 |
# File 'lib/vedeu/output/presentation.rb', line 117 def render_style [ style, yield, parent_style ].join end |
#style ⇒ Vedeu::Style
47 48 49 |
# File 'lib/vedeu/output/presentation.rb', line 47 def style Vedeu::Style.coerce(@style) end |
#style=(value) ⇒ Vedeu::Style
52 53 54 |
# File 'lib/vedeu/output/presentation.rb', line 52 def style=(value) @style = Vedeu::Style.coerce(value) end |
#to_s ⇒ String
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.
61 62 63 |
# File 'lib/vedeu/output/presentation.rb', line 61 def to_s render_position { render_colour { render_style { render_border { value } } } } end |