Class: Contactually::Collection
- Inherits:
-
Object
- Object
- Contactually::Collection
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/contactually/collection.rb
Instance Attribute Summary collapse
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#next_page ⇒ Object
readonly
Returns the value of attribute next_page.
-
#previous_page ⇒ Object
readonly
Returns the value of attribute previous_page.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
Instance Method Summary collapse
- #each(&block) ⇒ Object
- #has_next_page? ⇒ Boolean
- #has_previous_page? ⇒ Boolean
-
#initialize(items, meta: {}) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(items, meta: {}) ⇒ Collection
Returns a new instance of Collection.
8 9 10 11 12 13 14 |
# File 'lib/contactually/collection.rb', line 8 def initialize(items, meta: {}) @items = items @next_page = ['next_page'] @previous_page = ['previous_page'] @total = ['total'] end |
Instance Attribute Details
#items ⇒ Object (readonly)
Returns the value of attribute items.
6 7 8 |
# File 'lib/contactually/collection.rb', line 6 def items @items end |
#next_page ⇒ Object (readonly)
Returns the value of attribute next_page.
6 7 8 |
# File 'lib/contactually/collection.rb', line 6 def next_page @next_page end |
#previous_page ⇒ Object (readonly)
Returns the value of attribute previous_page.
6 7 8 |
# File 'lib/contactually/collection.rb', line 6 def previous_page @previous_page end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
6 7 8 |
# File 'lib/contactually/collection.rb', line 6 def total @total end |
Instance Method Details
#each(&block) ⇒ Object
16 17 18 19 20 |
# File 'lib/contactually/collection.rb', line 16 def each(&block) items.each do |item| block.call(item) end end |
#has_next_page? ⇒ Boolean
22 23 24 |
# File 'lib/contactually/collection.rb', line 22 def has_next_page? !next_page.nil? end |
#has_previous_page? ⇒ Boolean
26 27 28 |
# File 'lib/contactually/collection.rb', line 26 def has_previous_page? !previous_page.nil? end |