Class: Vedeu::Views::Composition

Inherits:
Object
  • Object
show all
Includes:
Presentation, Repositories::Model, Value
Defined in:
lib/vedeu/views/composition.rb

Overview

A composition is a collection of interfaces.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Vedeu::Views::Composition

Returns a new instance of Vedeu::Views::Composition.

Options Hash (attributes):



33
34
35
36
37
# File 'lib/vedeu/views/composition.rb', line 33

def initialize(attributes = {})
  defaults.merge!(attributes).each do |key, value|
    instance_variable_set("@#{key}", value)
  end
end

Instance Attribute Details

#repositoryVedeu::Repositories::Repository Originally defined in module Repositories::Model

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.

#add(child) ⇒ Vedeu::Views::Views Also known as: <<



41
42
43
# File 'lib/vedeu/views/composition.rb', line 41

def add(child)
  @value = value.add(child)
end

#attributesHash<Symbol => void>



47
48
49
50
51
52
53
54
55
# File 'lib/vedeu/views/composition.rb', line 47

def attributes
  {
    client: client,
    colour: colour,
    parent: parent,
    style:  style,
    value:  value,
  }
end

#backgroundVedeu::Colours::Background Originally defined in module Presentation::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 Presentation::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.

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

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

#colourVedeu::Colours::Colour Originally defined in module Presentation::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 Presentation::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 Presentation::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.

#defaultsHash (private)

The default values for a new instance of this class.



72
73
74
75
76
77
78
79
80
# File 'lib/vedeu/views/composition.rb', line 72

def defaults
  {
    client: nil,
    colour: nil,
    parent: nil,
    style:  nil,
    value:  [],
  }
end

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

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

#foregroundVedeu::Colours::Foreground Originally defined in module Presentation::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 Presentation::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.

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

#nameNilClass|String|Symbol Originally defined in module Presentation::Styles

#named_colourVedeu::Colours::Colour (private) Originally defined in module Presentation::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 Presentation::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.

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

#parentNilClass|void Originally defined in module Presentation::Styles

#parent_colourVedeu::Colours::Colour (private) Originally defined in module Presentation::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 Presentation::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.

#positionVedeu::Geometries::Position Originally defined in module Presentation::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 Presentation::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.

#position?Boolean Originally defined in module Presentation::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.

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

#render_colour(&block) ⇒ String (private) Originally defined in module Presentation

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

#render_position(&block) ⇒ String (private) Originally defined in module Presentation

#render_style(&block) ⇒ String (private) Originally defined in module Presentation

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

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

#store(&block) ⇒ void Originally defined in module Repositories::Model

TODO:

Perhaps some validation could be added here?

Note:

If a block is given, store the model, return the model after yielding.

This method returns an undefined value.

Returns The model instance stored in the repository.

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

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

#styleVedeu::Presentation::Style Originally defined in module Presentation::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 Presentation::Styles

Allows the setting of the style by coercing the given value into a Vedeu::Presentation::Style.

#to_sString Also known as: to_str Originally defined in module Presentation

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.

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

#update_buffers(refresh = false) ⇒ Vedeu::Views::Composition



61
62
63
64
65
# File 'lib/vedeu/views/composition.rb', line 61

def update_buffers(refresh = false)
  views.each { |view| view.update_buffer(refresh) } if views?

  self
end

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

#xFixnum|NilClass Originally defined in module Presentation::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.

#yFixnum|NilClass Originally defined in module Presentation::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.