Class: Envato::Collection
- Inherits:
-
Object
- Object
- Envato::Collection
- Defined in:
- lib/envato/collection.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
TODO: links: { next_page_url, prev_page_url, first_page_url, last_page_url } TODO: total_hits: TODO: took:.
-
#items ⇒ Object
readonly
TODO: links: { next_page_url, prev_page_url, first_page_url, last_page_url } TODO: total_hits: TODO: took:.
-
#total ⇒ Object
readonly
TODO: links: { next_page_url, prev_page_url, first_page_url, last_page_url } TODO: total_hits: TODO: took:.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data:, items:, total:) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(data:, items:, total:) ⇒ Collection
Returns a new instance of Collection.
19 20 21 22 23 |
# File 'lib/envato/collection.rb', line 19 def initialize(data:, items:, total:) @data = data @items = items @total = total end |
Instance Attribute Details
#data ⇒ Object (readonly)
TODO: links: { next_page_url, prev_page_url, first_page_url, last_page_url } TODO: total_hits: TODO: took:
8 9 10 |
# File 'lib/envato/collection.rb', line 8 def data @data end |
#items ⇒ Object (readonly)
TODO: links: { next_page_url, prev_page_url, first_page_url, last_page_url } TODO: total_hits: TODO: took:
8 9 10 |
# File 'lib/envato/collection.rb', line 8 def items @items end |
#total ⇒ Object (readonly)
TODO: links: { next_page_url, prev_page_url, first_page_url, last_page_url } TODO: total_hits: TODO: took:
8 9 10 |
# File 'lib/envato/collection.rb', line 8 def total @total end |
Class Method Details
.from_response(response, key:, type:) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/envato/collection.rb', line 10 def self.from_response(response, key:, type:) body = response.body new( data: body[key].map {|attrs| type.new(attrs) }, items: body["items"], total: body["total"] ) end |