Class: Vedeu::Models::Row
- Inherits:
-
Object
- Object
- Vedeu::Models::Row
- 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
Class Method Summary collapse
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
- #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.
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#initialize(cells = []) ⇒ Vedeu::Models::Row
constructor
Returns a new instance of Vedeu::Models::Row.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#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
-
#snake_case(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
Constructor Details
#initialize(cells = []) ⇒ Vedeu::Models::Row
Returns a new instance of Vedeu::Models::Row.
40 41 42 |
# File 'lib/vedeu/models/row.rb', line 40 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 |
Class Method Details
.coerce(value) ⇒ Vedeu::Models::Row
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/vedeu/models/row.rb', line 20 def self.coerce(value) if value.is_a?(self) value elsif value.is_a?(Array) new(value.compact) elsif value.nil? new else new([value]) end end |
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.
#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.
#cell(index) ⇒ NilClass|void
46 47 48 49 50 |
# File 'lib/vedeu/models/row.rb', line 46 def cell(index) return nil if index.nil? || empty? cells[index] end |
#content ⇒ Array<void>
53 54 55 |
# File 'lib/vedeu/models/row.rb', line 53 def content (cells.flatten << reset_character) end |
#each(&block) ⇒ Enumerator
Provides iteration over the collection.
61 62 63 |
# File 'lib/vedeu/models/row.rb', line 61 def each(&block) cells.each(&block) end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
74 75 76 |
# File 'lib/vedeu/models/row.rb', line 74 def eql?(other) self.class == other.class && cells == other.cells 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.
#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.
#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.
#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.
#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.
84 85 86 |
# File 'lib/vedeu/models/row.rb', line 84 def reset_character Vedeu::Cells::Escape.new(value: Vedeu.esc.reset) end |
#size ⇒ Fixnum
89 90 91 |
# File 'lib/vedeu/models/row.rb', line 89 def size cells.size end |
#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.
#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.
#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.
#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.