Class: Fera::Collection
- Inherits:
-
ActiveResource::Collection
- Object
- ActiveResource::Collection
- Fera::Collection
- Defined in:
- lib/fera/models/collection.rb
Instance Attribute Summary collapse
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#page_size ⇒ Object
readonly
Returns the value of attribute page_size.
-
#result_count ⇒ Object
readonly
Returns the value of attribute result_count.
-
#total_count ⇒ Object
readonly
Returns the value of attribute total_count.
-
#total_pages ⇒ Object
readonly
Returns the value of attribute total_pages.
Instance Method Summary collapse
-
#initialize(parsed = {}) ⇒ Collection
constructor
A new instance of Collection.
- #using_pagination? ⇒ Boolean
Constructor Details
#initialize(parsed = {}) ⇒ Collection
Returns a new instance of Collection.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/fera/models/collection.rb', line 7 def initialize(parsed = {}) super(parsed['data']) @result_count = parsed['result_count'] @total_count = parsed['total_count'] @using_pagination = parsed.key?('page') if @using_pagination @page = parsed['page'] @total_pages = parsed['total_pages'] @page_size = parsed['page_size'] else @offset = parsed['offset'] @limit = parsed['limit'] end end |
Instance Attribute Details
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def limit @limit end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def offset @offset end |
#page ⇒ Object (readonly)
Returns the value of attribute page.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def page @page end |
#page_size ⇒ Object (readonly)
Returns the value of attribute page_size.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def page_size @page_size end |
#result_count ⇒ Object (readonly)
Returns the value of attribute result_count.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def result_count @result_count end |
#total_count ⇒ Object (readonly)
Returns the value of attribute total_count.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def total_count @total_count end |
#total_pages ⇒ Object (readonly)
Returns the value of attribute total_pages.
5 6 7 |
# File 'lib/fera/models/collection.rb', line 5 def total_pages @total_pages end |
Instance Method Details
#using_pagination? ⇒ Boolean
24 |
# File 'lib/fera/models/collection.rb', line 24 def using_pagination?; @using_pagination; end |