Class: Fopost::Page
Overview
One page of a list endpoint: its items plus the pagination meta.
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#meta ⇒ Object
readonly
Returns the value of attribute meta.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(items: [], meta: PageMeta.new) ⇒ Page
constructor
A new instance of Page.
- #inspect ⇒ Object
- #size ⇒ Object (also: #length, #count)
Constructor Details
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
139 140 141 |
# File 'lib/fopost/models.rb', line 139 def items @items end |
#meta ⇒ Object (readonly)
Returns the value of attribute meta.
139 140 141 |
# File 'lib/fopost/models.rb', line 139 def @meta end |
Instance Method Details
#[](index) ⇒ Object
153 154 155 |
# File 'lib/fopost/models.rb', line 153 def [](index) items[index] end |
#each(&block) ⇒ Object
146 147 148 149 150 151 |
# File 'lib/fopost/models.rb', line 146 def each(&block) return items.each unless block items.each(&block) self end |
#empty? ⇒ Boolean
163 164 165 |
# File 'lib/fopost/models.rb', line 163 def empty? items.empty? end |
#inspect ⇒ Object
167 168 169 |
# File 'lib/fopost/models.rb', line 167 def inspect "#<Fopost::Page items=#{items.size} total=#{.total.inspect}>" end |
#size ⇒ Object Also known as: length, count
157 158 159 |
# File 'lib/fopost/models.rb', line 157 def size items.size end |