Class: Vedeu::Cells::Empty Private

Inherits:
Object
  • Object
show all
Includes:
Presentation, Repositories::Defaults
Defined in:
lib/vedeu/cells/empty.rb

Overview

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

Provides the character/escape sequence to draw one cell of a with a custom value, colour and style.

The Vedeu::Cells::Empty object represents an empty cell with no content and is the basis of all the Vedeu::Cells objects.

Direct Known Subclasses

Border, Char, Clear, Cursor, Escape

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameString|Symbol (readonly)

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 name of the interface/view this cell belongs to.



23
24
25
# File 'lib/vedeu/cells/empty.rb', line 23

def name
  @name
end

#valueString (readonly)

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.



27
28
29
# File 'lib/vedeu/cells/empty.rb', line 27

def value
  @value
end

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Vedeu::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.

#as_htmlString

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 value represented as HTML.



32
33
34
# File 'lib/vedeu/cells/empty.rb', line 32

def as_html
  ' '
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 Vedeu::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 Vedeu::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 Vedeu::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.

#borderVedeu::Borders::Border (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.



111
112
113
# File 'lib/vedeu/cells/empty.rb', line 111

def border
  Vedeu.borders.by_name(name)
end

#cell?Boolean

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.



37
38
39
# File 'lib/vedeu/cells/empty.rb', line 37

def cell?
  true
end

#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<Symbol => Hash<void>|NilClass|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.



100
101
102
103
104
105
106
107
108
# File 'lib/vedeu/cells/empty.rb', line 100

def defaults
  {
    colour:   {},
    name:     '',
    position: nil,
    style:    '',
    value:    '',
  }
end

#eql?(other) ⇒ Boolean Also known as: ==

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.

An object is equal when its values are the same.



45
46
47
48
49
50
# File 'lib/vedeu/cells/empty.rb', line 45

def eql?(other)
  self.class == other.class    &&
    position == other.position &&
    value    == other.value    &&
    colour   == other.colour
end

#escape?(value) ⇒ Boolean Originally defined in module Vedeu::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 Vedeu::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.

#geometryVedeu::Geometries::Geometry (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.



116
117
118
# File 'lib/vedeu/cells/empty.rb', line 116

def geometry
  Vedeu.geometries.by_name(name)
end

#hash?(value) ⇒ Boolean Originally defined in module Vedeu::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.

#initialize(attributes = {}) ⇒ void Originally defined in module Repositories::Defaults

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.

Note:

If a particular key is missing from the attributes parameter, then it is added with the respective value from #defaults.

Returns a new instance of the class including this module.

#interfaceVedeu::Interfaces::Interface (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.



121
122
123
# File 'lib/vedeu/cells/empty.rb', line 121

def interface
  Vedeu.interfaces.by_name(name)
end

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

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

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

#textString

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.



54
55
56
# File 'lib/vedeu/cells/empty.rb', line 54

def text
  ' '
end

#to_astString

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.



59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/vedeu/cells/empty.rb', line 59

def to_ast
  [
    '[',
    [
      position.to_ast,
      colour.to_ast,
      style.to_ast,
      ":#{type}",
    ].reject(&:empty?).join(' '),
    ']',
  ].join
end

#to_hHash<Symbol => Hash<Symbol => String>, String> Also known as: to_hash

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.



73
74
75
76
77
78
79
80
# File 'lib/vedeu/cells/empty.rb', line 73

def to_h
  {
    name:  name.to_s,
    style: style.to_s,
    type:  type,
    value: value.to_s,
  }.merge!(colour.to_h).merge!(position.to_h)
end

#to_html(options = {}) ⇒ String

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 object represented as HTML.



88
89
90
# File 'lib/vedeu/cells/empty.rb', line 88

def to_html(options = {})
  Vedeu::Cells::HTML.new(self, options).to_html
end

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

#typeSymbol

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.



93
94
95
# File 'lib/vedeu/cells/empty.rb', line 93

def type
  :empty
end

#validate(attributes) ⇒ Hash (private) Originally defined in module Repositories::Defaults

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.

Raises:

  • (Vedeu::Error::InvalidSyntax)

    When the value given for an argument or parameter cannot be used because it is not valid for the use case, unsupported or the method expects a different type.

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