Class: Vedeu::Models::Page
- Inherits:
-
Object
- Object
- Vedeu::Models::Page
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/vedeu/models/page.rb
Overview
A Page represents an array of Vedeu::Models::Row objects.
Instance Attribute Summary collapse
Instance Method Summary collapse
- #cell(row_index = nil, cell_index = nil) ⇒ 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(rows = []) ⇒ Vedeu::Models::Page
constructor
Returns a new instance of Vedeu::Models::Page.
- #row(index = nil) ⇒ NilClass|Vedeu::Models::Row
- #size ⇒ Fixnum
Constructor Details
#initialize(rows = []) ⇒ Vedeu::Models::Page
Returns a new instance of Vedeu::Models::Page.
30 31 32 |
# File 'lib/vedeu/models/page.rb', line 30 def initialize(rows = []) @rows = rows || [] end |
Instance Attribute Details
#rows ⇒ Array<NilClass|Vedeu::Models::Row> (readonly)
15 16 17 |
# File 'lib/vedeu/models/page.rb', line 15 def rows @rows end |
Instance Method Details
#cell(row_index = nil, cell_index = nil) ⇒ NilClass|void
42 43 44 45 46 47 |
# File 'lib/vedeu/models/page.rb', line 42 def cell(row_index = nil, cell_index = nil) return nil if row_index.nil? || cell_index.nil? return nil unless row(row_index) row(row_index)[cell_index] end |
#content ⇒ Array<void>
35 36 37 |
# File 'lib/vedeu/models/page.rb', line 35 def content rows.flat_map(&:content) end |
#each(&block) ⇒ Enumerator
Provides iteration over the collection.
53 54 55 |
# File 'lib/vedeu/models/page.rb', line 53 def each(&block) rows.each(&block) end |
#eql?(other) ⇒ Boolean Also known as: ==
An object is equal when its values are the same.
66 67 68 |
# File 'lib/vedeu/models/page.rb', line 66 def eql?(other) self.class.equal?(other.class) && rows == other.rows end |
#row(index = nil) ⇒ NilClass|Vedeu::Models::Row
73 74 75 76 77 |
# File 'lib/vedeu/models/page.rb', line 73 def row(index = nil) return nil if index.nil? rows[index] end |
#size ⇒ Fixnum
80 81 82 |
# File 'lib/vedeu/models/page.rb', line 80 def size rows.size end |