Class: Vedeu::Models::Row Private

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Enumerable, Common
Defined in:
lib/vedeu/models/row.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.

A Row represents an array of Vedeu::Cells::Empty objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Common

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

Constructor Details

#initialize(cells = []) ⇒ Vedeu::Models::Row

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 instance of Vedeu::Models::Row.

Parameters:

  • cells (Array<NilClass|void>) (defaults to: [])


33
34
35
# File 'lib/vedeu/models/row.rb', line 33

def initialize(cells = [])
  @cells = cells || []
end

Instance Attribute Details

#cellsArray<NilClass|void> (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:

  • (Array<NilClass|void>)


18
19
20
# File 'lib/vedeu/models/row.rb', line 18

def cells
  @cells
end

Instance Method Details

#cell(index) ⇒ NilClass|void

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.

Parameters:

  • index (Fixnum)

Returns:

  • (NilClass|void)


39
40
41
42
43
# File 'lib/vedeu/models/row.rb', line 39

def cell(index)
  return nil if index.nil? || empty?

  cells[index]
end

#contentArray<void>

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:

  • (Array<void>)


46
47
48
# File 'lib/vedeu/models/row.rb', line 46

def content
  (cells.flatten << reset_character)
end

#each(&block) ⇒ Enumerator

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.

Provides iteration over the collection.

Parameters:

  • block (Proc)

Returns:

  • (Enumerator)


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

def each(&block)
  cells.each(&block)
end

#empty?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:



59
60
61
# File 'lib/vedeu/models/row.rb', line 59

def empty?
  cells.empty?
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:

Returns:



67
68
69
# File 'lib/vedeu/models/row.rb', line 67

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

#reset_characterVedeu::Cells::Escape

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.

Provides the reset escape sequence at the end of a row to reset colour and style information to prevent colour bleed on the next line.



77
78
79
# File 'lib/vedeu/models/row.rb', line 77

def reset_character
  Vedeu::Cells::Escape.new(value: Vedeu.esc.reset)
end

#sizeFixnum

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:

  • (Fixnum)


82
83
84
# File 'lib/vedeu/models/row.rb', line 82

def size
  cells.size
end