Class: Yar::Collection
- Inherits:
-
Object
- Object
- Yar::Collection
- Defined in:
- lib/Yar/collection.rb,
lib/yar/collection.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#items ⇒ Object
readonly
Returns the value of attribute items.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
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.
16 17 18 19 20 |
# File 'lib/Yar/collection.rb', line 16 def initialize(data:, items:, total:) @data = data @items = items @total = total end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/Yar/collection.rb', line 5 def data @data end |
#items ⇒ Object (readonly)
Returns the value of attribute items.
5 6 7 |
# File 'lib/Yar/collection.rb', line 5 def items @items end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
5 6 7 |
# File 'lib/Yar/collection.rb', line 5 def total @total end |
Class Method Details
.from_response(response, key:, type:) ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/Yar/collection.rb', line 7 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 |