Class: Vedeu::Models::Row
- Inherits:
-
Object
- Object
- Vedeu::Models::Row
- Extended by:
- Forwardable
- Includes:
- Enumerable, Common
- Defined in:
- lib/vedeu/models/row.rb
Overview
A Row represents an array of Vedeu::Cells::Empty objects.
Instance Attribute Summary collapse
- #cells ⇒ Array<NilClass|void> readonly
Instance Method Summary collapse
- #cell(index) ⇒ NilClass|void
- #content ⇒ Array<void>
-
#each(&block) ⇒ Enumerator
Provides iteration over the collection.
- #empty? ⇒ Boolean
-
#eql?(other) ⇒ Boolean
(also: #==)
An object is equal when its values are the same.
-
#initialize(cells = []) ⇒ Vedeu::Models::Row
constructor
Returns a new instance of Vedeu::Models::Row.
-
#reset_character ⇒ Vedeu::Cells::Escape
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.
- #size ⇒ Fixnum
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
Returns a new instance of Vedeu::Models::Row.
31 32 33 |
# File 'lib/vedeu/models/row.rb', line 31 def initialize(cells = []) @cells = cells || [] end |
Instance Attribute Details
#cells ⇒ Array<NilClass|void> (readonly)
16 17 18 |
# File 'lib/vedeu/models/row.rb', line 16 def cells @cells end |
Instance Method Details
#cell(index) ⇒ NilClass|void
37 38 39 40 41 |
# File 'lib/vedeu/models/row.rb', line 37 def cell(index) return nil if index.nil? || empty? cells[index] end |
#content ⇒ Array<void>
44 45 46 |
# File 'lib/vedeu/models/row.rb', line 44 def content (cells.flatten << reset_character) end |
#each(&block) ⇒ Enumerator
Provides iteration over the collection.
52 53 54 |
# File 'lib/vedeu/models/row.rb', line 52 def each(&block) cells.each(&block) end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
65 66 67 |
# File 'lib/vedeu/models/row.rb', line 65 def eql?(other) self.class.equal?(other.class) && cells == other.cells end |
#reset_character ⇒ Vedeu::Cells::Escape
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.
75 76 77 |
# File 'lib/vedeu/models/row.rb', line 75 def reset_character Vedeu::Cells::Escape.new(value: Vedeu.esc.reset) end |
#size ⇒ Fixnum
80 81 82 |
# File 'lib/vedeu/models/row.rb', line 80 def size cells.size end |