Module: Vedeu::Presentation

Includes:
Colour, Position, Styles
Included in:
Borders::Border, Cells::Border, Cells::Empty, Interfaces::Interface, Interfaces::Null, Output::Write, Views::Composition, Views::Line, Views::Stream, Views::View
Defined in:
lib/vedeu/presentation/all.rb,
lib/vedeu/presentation/style.rb,
lib/vedeu/presentation/colour.rb,
lib/vedeu/presentation/styles.rb,
lib/vedeu/presentation/position.rb,
lib/vedeu/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, Position, Styles Classes: Style

Instance Method Summary collapse

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#backgroundVedeu::Colours::Background Originally defined in module Colour

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.

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

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.

Allows the setting of the background colour by coercing the given value into a Vedeu::Colours::Background colour.

#become(klass, attributes) ⇒ Class Originally defined in module Common

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 one class into another.

Parameters:

  • klass (Class)

    The class to become an instance of.

  • attributes (Hash)

    The attributes of klass.

Returns:

  • (Class)

    Returns a new instance of klass.

#boolean(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating the value was a boolean.

Parameters:

  • value (void)

Returns:

#boolean?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Boolean.

Parameters:

Returns:

#colourVedeu::Colours::Colour Originally defined in module Colour

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.

#colour=(value) ⇒ Vedeu::Colours::Colour Originally defined in module Colour

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.

Allows the setting of the model’s colour by coercing the given value into a Vedeu::Colours::Colour.

#colour?Boolean Originally defined in module Colour

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:

#escape?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)

Returns:

#falsy?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value should be considered false.

Parameters:

  • value (void)

Returns:

#foregroundVedeu::Colours::Foreground Originally defined in module Colour

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.

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

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.

Allows the setting of the foreground colour by coercing the given value into a Vedeu::Colours::Foreground colour.

#hash?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Hash.

Parameters:

  • value (Hash|void)

Returns:

#line_model?Boolean Originally defined in module Common

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 boolean indicating the model is a Views::Line.

Returns:

#nameNilClass|String|Symbol Originally defined in module Styles

Returns:

  • (NilClass|String|Symbol)

#named_colourVedeu::Colours::Colour (private) Originally defined in module Colour

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.

#named_colour?Boolean (private) Originally defined in module Colour

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:

#numeric?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Fixnum.

Parameters:

  • value (Fixnum|void)

Returns:

#parentNilClass|void Originally defined in module Styles

Returns:

  • (NilClass|void)

#parent_colourVedeu::Colours::Colour (private) Originally defined in module Colour

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.

#parent_colour?Boolean (private) Originally defined in module Colour

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:

#positionVedeu::Geometries::Position Originally defined in module Position

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.

Gets the position.

#position=(value) ⇒ Vedeu::Geometries::Position Originally defined in module Position

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.

Sets the position.

Parameters:

Returns:

#position?Boolean Originally defined in module Position

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 boolean indicating the position attribute of the including model is set.

Returns:

#present?(variable) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

#render_colour(&block) ⇒ String (private)

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

Parameters:

  • block (Proc)

Returns:

  • (String)


28
29
30
# File 'lib/vedeu/presentation/presentation.rb', line 28

def render_colour(&block)
  "#{colour}#{yield}"
end

#render_position(&block) ⇒ String (private)

Parameters:

  • block (Proc)

Returns:

  • (String)


34
35
36
37
38
# File 'lib/vedeu/presentation/presentation.rb', line 34

def render_position(&block)
  return position.to_s { yield } if position?

  yield
end

#render_style(&block) ⇒ String (private)

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

Parameters:

  • block (Proc)

Returns:

  • (String)


45
46
47
# File 'lib/vedeu/presentation/presentation.rb', line 45

def render_style(&block)
  "#{style}#{yield}"
end

#snake_case(klass) ⇒ String Originally defined in module Common

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 a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

snake_case('MyClassName') # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • klass (Module|Class|String)

Returns:

  • (String)

#stream_model?Boolean Originally defined in module Common

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 boolean indicating the model is a Views::Stream.

Returns:

#string?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value is a Fixnum.

Parameters:

  • value (String|void)

Returns:

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



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

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

#truthy?(value) ⇒ Boolean Originally defined in module Common

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 boolean indicating whether the value should be considered true.

Parameters:

  • value (void)

Returns:

#view_model?Boolean Originally defined in module Common

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 boolean indicating the model is a Views::View.

Returns:

#xFixnum|NilClass Originally defined in module Position

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 x coordinate for the model when the position attribute of the including model is set.

Returns:

  • (Fixnum|NilClass)

#yFixnum|NilClass Originally defined in module Position

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 y coordinate for the model when the position attribute of the including model is set.

Returns:

  • (Fixnum|NilClass)