Class: Pin::CollectionResponse
- Inherits:
-
Object
- Object
- Pin::CollectionResponse
- Defined in:
- lib/pin-payments/response.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#page_count ⇒ Object
readonly
Returns the value of attribute page_count.
-
#per_page ⇒ Object
readonly
Returns the value of attribute per_page.
Instance Method Summary collapse
- #first_page? ⇒ Boolean
-
#initialize(collection, per_page, page_count, current_page) ⇒ CollectionResponse
constructor
A new instance of CollectionResponse.
- #last_page? ⇒ Boolean
- #method_missing(meth, *args, &block) ⇒ Object
- #next_page? ⇒ Boolean
- #previous_page? ⇒ Boolean
Constructor Details
#initialize(collection, per_page, page_count, current_page) ⇒ CollectionResponse
Returns a new instance of CollectionResponse.
5 6 7 8 9 10 |
# File 'lib/pin-payments/response.rb', line 5 def initialize(collection, per_page, page_count, current_page) @collection = collection @page_count = page_count @per_page = per_page @page = current_page end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/pin-payments/response.rb', line 28 def method_missing(meth, *args, &block) if collection.respond_to?(meth) collection.send(meth, *args, &block) else super end end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
3 4 5 |
# File 'lib/pin-payments/response.rb', line 3 def collection @collection end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
3 4 5 |
# File 'lib/pin-payments/response.rb', line 3 def page @page end |
#page_count ⇒ Object (readonly)
Returns the value of attribute page_count.
3 4 5 |
# File 'lib/pin-payments/response.rb', line 3 def page_count @page_count end |
#per_page ⇒ Object (readonly)
Returns the value of attribute per_page.
3 4 5 |
# File 'lib/pin-payments/response.rb', line 3 def per_page @per_page end |
Instance Method Details
#first_page? ⇒ Boolean
12 13 14 |
# File 'lib/pin-payments/response.rb', line 12 def first_page? @page == 1 end |
#last_page? ⇒ Boolean
16 17 18 |
# File 'lib/pin-payments/response.rb', line 16 def last_page? @page == @page_count end |
#next_page? ⇒ Boolean
20 21 22 |
# File 'lib/pin-payments/response.rb', line 20 def next_page? @page_count > 1 && !last_page? end |
#previous_page? ⇒ Boolean
24 25 26 |
# File 'lib/pin-payments/response.rb', line 24 def previous_page? @page_count > 1 && !first_page? end |