Class: RivetCms::EntryCollection
- Inherits:
-
Object
- Object
- RivetCms::EntryCollection
- Includes:
- Enumerable
- Defined in:
- app/models/rivet_cms/entry_collection.rb
Overview
Enumerable page of entries with the pagination numbers host views need.
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(entries, page: 1, per_page: entries.size, total: entries.size, total_pages: 1) ⇒ EntryCollection
constructor
A new instance of EntryCollection.
- #inspect ⇒ Object
- #size ⇒ Object (also: #length)
- #to_a ⇒ Object
Constructor Details
#initialize(entries, page: 1, per_page: entries.size, total: entries.size, total_pages: 1) ⇒ EntryCollection
Returns a new instance of EntryCollection.
8 9 10 11 12 13 14 |
# File 'app/models/rivet_cms/entry_collection.rb', line 8 def initialize(entries, page: 1, per_page: entries.size, total: entries.size, total_pages: 1) @entries = entries @page = page @per_page = per_page @total = total @total_pages = total_pages end |
Instance Attribute Details
#page ⇒ Object (readonly)
Returns the value of attribute page.
6 7 8 |
# File 'app/models/rivet_cms/entry_collection.rb', line 6 def page @page end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
6 7 8 |
# File 'app/models/rivet_cms/entry_collection.rb', line 6 def per_page @per_page end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'app/models/rivet_cms/entry_collection.rb', line 6 def total @total end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
6 7 8 |
# File 'app/models/rivet_cms/entry_collection.rb', line 6 def total_pages @total_pages end |
Instance Method Details
#[](index) ⇒ Object
29 30 31 |
# File 'app/models/rivet_cms/entry_collection.rb', line 29 def [](index) @entries[index] end |
#each(&block) ⇒ Object
16 17 18 |
# File 'app/models/rivet_cms/entry_collection.rb', line 16 def each(&block) @entries.each(&block) end |
#empty? ⇒ Boolean
33 34 35 |
# File 'app/models/rivet_cms/entry_collection.rb', line 33 def empty? @entries.empty? end |
#inspect ⇒ Object
37 38 39 |
# File 'app/models/rivet_cms/entry_collection.rb', line 37 def inspect "#<RivetCms::EntryCollection size=#{size} page=#{page}/#{total_pages} total=#{total}>" end |
#size ⇒ Object Also known as: length
24 25 26 |
# File 'app/models/rivet_cms/entry_collection.rb', line 24 def size @entries.size end |
#to_a ⇒ Object
20 21 22 |
# File 'app/models/rivet_cms/entry_collection.rb', line 20 def to_a @entries.dup end |