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

Instance Method Details

#backgroundVedeu::Background|NilClass

Returns:



9
10
11
12
13
# File 'lib/vedeu/output/presentation.rb', line 9

def background
  if colour
    colour.background
  end
end

#colourVedeu::Colour

Returns:



37
38
39
# File 'lib/vedeu/output/presentation.rb', line 37

def colour
  Vedeu::Colour.coerce(@colour)
end

#colour=(value) ⇒ Vedeu::Colour

Returns:



42
43
44
# File 'lib/vedeu/output/presentation.rb', line 42

def colour=(value)
  @colour = Vedeu::Colour.coerce(value)
end

#foregroundVedeu::Foreground|NilClass

Returns:



16
17
18
19
20
# File 'lib/vedeu/output/presentation.rb', line 16

def foreground
  if colour
    colour.foreground
  end
end

#parent_backgroundVedeu::Background|NilClass

Returns:



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_colourString|NilClass (private)

Returns:

  • (String|NilClass)


68
69
70
# File 'lib/vedeu/output/presentation.rb', line 68

def parent_colour
  parent.colour if parent
end

#parent_foregroundVedeu::Foreground|NilClass

Returns:



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_styleString|NilClass (private)

Returns:

  • (String|NilClass)


73
74
75
# File 'lib/vedeu/output/presentation.rb', line 73

def parent_style
  parent.style if parent
end

#render_borderString (private)

Returns:

  • (String)


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_colourString (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.

Returns:

  • (String)


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_positionString (private)

Returns:

  • (String)


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_styleString (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.

Returns:

  • (String)


117
118
119
120
121
122
123
# File 'lib/vedeu/output/presentation.rb', line 117

def render_style
  [
    style,
    yield,
    parent_style
  ].join
end

#styleVedeu::Style

Returns:



47
48
49
# File 'lib/vedeu/output/presentation.rb', line 47

def style
  Vedeu::Style.coerce(@style)
end

#style=(value) ⇒ Vedeu::Style

Returns:



52
53
54
# File 'lib/vedeu/output/presentation.rb', line 52

def style=(value)
  @style = Vedeu::Style.coerce(value)
end

#to_sString

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.

Returns:

  • (String)

    An escape sequence with value interpolated.



61
62
63
# File 'lib/vedeu/output/presentation.rb', line 61

def to_s
  render_position { render_colour { render_style { render_border { value } } } }
end