Module: Vedeu::Presentation Private

Included in:
Interface, Line, Stream
Defined in:
lib/vedeu/models/attributes/presentation.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

This module allows the sharing of presentation concerns between the models: Interface, Line and Stream.

Instance Method Summary collapse

Instance Method Details

#colourColour

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new Colour instance.

Returns:



22
23
24
# File 'lib/vedeu/models/attributes/presentation.rb', line 22

def colour
  @colour ||= Colour.new(attributes[:colour])
end

#parent_colourString (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the parent colour as an escape sequence if set.

Returns:

  • (String)


72
73
74
75
76
# File 'lib/vedeu/models/attributes/presentation.rb', line 72

def parent_colour
  return '' if parent.nil?

  Colour.new(parent[:colour]).to_s
end

#parent_styleString (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the parent style as an escape sequence if set.

Returns:

  • (String)


81
82
83
84
85
# File 'lib/vedeu/models/attributes/presentation.rb', line 81

def parent_style
  return '' if parent.nil?

  Style.new(parent[:style]).to_s
end

#render_colour(&block) ⇒ String (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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)


54
55
56
# File 'lib/vedeu/models/attributes/presentation.rb', line 54

def render_colour(&block)
  [ colour.to_s, yield, parent_colour ].join
end

#render_style(&block) ⇒ String (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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 colours back to those of the receiver’s parent.

Returns:

  • (String)


64
65
66
# File 'lib/vedeu/models/attributes/presentation.rb', line 64

def render_style(&block)
  [ style.to_s, yield, parent_style ].join
end

#styleStyle

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new Style instance.

Returns:



29
30
31
# File 'lib/vedeu/models/attributes/presentation.rb', line 29

def style
  @style ||= Style.new(attributes[:style])
end

#to_sString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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)


38
39
40
41
42
43
44
# File 'lib/vedeu/models/attributes/presentation.rb', line 38

def to_s
  render_colour do
    render_style do
      data
    end
  end
end

#view_attributesHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the colour and style attributes of the receiving class.

Returns:

  • (Hash)


12
13
14
15
16
17
# File 'lib/vedeu/models/attributes/presentation.rb', line 12

def view_attributes
  {
    colour: attributes[:colour],
    style:  attributes[:style],
  }
end