Class: Vedeu::Cells::Empty Private

Inherits:
Object
  • Object
show all
Includes:
Presentation, Presentation::Colour, Presentation::Position, Presentation::Styles, 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

Methods included from Repositories::Defaults

#initialize, #validate

Methods included from Vedeu::Common

#absent?, #array?, #boolean, #boolean?, #empty_value?, #escape?, #falsy?, #hash?, #line_model?, #numeric?, #positionable?, #present?, #snake_case, #stream_model?, #string?, #symbol?, #truthy?, #view_model?

Methods included from Presentation::Styles

#render_style, #style, #style=, #style?

Methods included from Presentation::Parent

#parent, #parent?

Methods included from Presentation::Position

#position, #position=, #position?, #render_position, #x, #y

Methods included from Presentation::Colour

#background, #background=, #colour, #colour=, #colour?, #foreground, #foreground=, #named_colour, #named_colour?, #parent_colour, #parent_colour?, #render_colour

Methods included from Presentation

#to_s

Instance Attribute Details

#nameNilClass|Symbol|String (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 model, the target model or the name of the associated model.

Returns:

  • (NilClass|Symbol|String)

    The name of the model, the target model or the name of the associated model.



25
26
27
# File 'lib/vedeu/cells/empty.rb', line 25

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.

Returns:

  • (String)


29
30
31
# File 'lib/vedeu/cells/empty.rb', line 29

def value
  @value
end

Instance Method Details

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

Returns:

  • (String)


34
35
36
# File 'lib/vedeu/cells/empty.rb', line 34

def as_html
  ' '
end

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

Returns the named border from the borders repository.



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

def border
  Vedeu.borders.by_name(name)
end

#defaultsHash<Symbol => void> (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.

The default options/attributes for a new instance of this class.

Returns:

  • (Hash<Symbol => void>)


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

def defaults
  {
    colour:   {},
    name:     nil,
    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.

Parameters:

  • other (void)

Returns:



42
43
44
# File 'lib/vedeu/cells/empty.rb', line 42

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

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

Returns the named geometry from the geometries repository.



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

def geometry
  Vedeu.geometries.by_name(name)
end

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

Returns the named interface/view from the interfaces repository.



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

def interface
  Vedeu.interfaces.by_name(name)
end

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

Returns:

  • (String)


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

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.

Returns:

  • (String)


53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/vedeu/cells/empty.rb', line 53

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.

Returns:

  • (Hash<Symbol => Hash<Symbol => String>, String>)


67
68
69
70
71
72
73
74
# File 'lib/vedeu/cells/empty.rb', line 67

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.

Parameters:

  • options (Hash) (defaults to: {})

    Options provided by Renderers::HTML.

Returns:

  • (String)


82
83
84
# File 'lib/vedeu/cells/empty.rb', line 82

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

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

Returns:

  • (Symbol)


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

def type
  :empty
end

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

Returns:



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

def value?
  present?(value)
end