Module: Vedeu::Presentation

Includes:
Colour, Styles
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

Instance Method Details

#backgroundVedeu::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.

#colourVedeu::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.

#foregroundVedeu::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.

Returns:

  • (Boolean)


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

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

Returns:

  • (String)


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

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

#render_positionString (private)

Returns:

  • (String)


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

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

Returns:

  • (String)


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

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

#styleVedeu::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_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.

Returns:

  • (String)

    An escape sequence with value interpolated.



13
14
15
# File 'lib/vedeu/output/presentation/presentation.rb', line 13

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