Class: Vedeu::Models::Page

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(rows = []) ⇒ Vedeu::Models::Page

Returns a new instance of Vedeu::Models::Page.

Parameters:



30
31
32
# File 'lib/vedeu/models/page.rb', line 30

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

Instance Attribute Details

#rowsArray<NilClass|Vedeu::Models::Row> (readonly)

Returns:



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

Parameters:

  • row_index (Fixnum) (defaults to: nil)
  • cell_index (Fixnum) (defaults to: nil)

Returns:

  • (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

#contentArray<void>

Returns:

  • (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.

Parameters:

  • block (Proc)

Returns:

  • (Enumerator)


53
54
55
# File 'lib/vedeu/models/page.rb', line 53

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

#empty?Boolean

Returns:



58
59
60
# File 'lib/vedeu/models/page.rb', line 58

def empty?
  rows.empty?
end

#eql?(other) ⇒ Boolean Also known as: ==

An object is equal when its values are the same.

Parameters:

Returns:



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

Parameters:

  • index (Fixnum) (defaults to: nil)

Returns:



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

#sizeFixnum

Returns:

  • (Fixnum)


80
81
82
# File 'lib/vedeu/models/page.rb', line 80

def size
  rows.size
end