Module: Vedeu::Presentation

Includes:
Colour, Styles
Included in:
Borders::Border, Models::Interface, Null::Interface, Null::View, Views::Char, Views::Composition, Views::Line, Views::Stream, Views::View
Defined in:
lib/vedeu/output/presentation/presentation.rb,
lib/vedeu/output/presentation/style.rb,
lib/vedeu/output/presentation/colour.rb,
lib/vedeu/output/presentation/styles.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

Methods included from Styles

#style, #style=

Methods included from Colour

#background, #background=, #colour, #colour=, #foreground, #foreground=

Instance Method Details

#render_colourString (private)

Renders the colour attributes of the receiver and yields (to then render the styles).



31
32
33
# File 'lib/vedeu/output/presentation/presentation.rb', line 31

def render_colour
  "#{colour}#{yield}"
end

#render_positionString (private)



36
37
38
39
40
41
42
43
44
45
# File 'lib/vedeu/output/presentation/presentation.rb', line 36

def render_position
  if self.respond_to?(:position) &&
     position.is_a?(Vedeu::Geometry::Position)
    position.to_s { yield }

  else
    yield

  end
end

#render_styleString (private)

Renders the style attributes of the receiver and yields (to then render the next model, or finally, the content).



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

def render_style
  "#{style}#{yield}"
end

#to_sString 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.



20
21
22
# File 'lib/vedeu/output/presentation/presentation.rb', line 20

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