Class: SmartRecruiters::Collection
- Inherits:
-
Object
- Object
- SmartRecruiters::Collection
- Defined in:
- lib/smartrecruiters/collection.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#next_page_id ⇒ Object
readonly
Returns the value of attribute next_page_id.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#total_found ⇒ Object
readonly
Returns the value of attribute total_found.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(content:, limit:, offset:, next_page_id:, total_found:) ⇒ Collection
constructor
A new instance of Collection.
Constructor Details
#initialize(content:, limit:, offset:, next_page_id:, total_found:) ⇒ Collection
Returns a new instance of Collection.
26 27 28 29 30 31 32 |
# File 'lib/smartrecruiters/collection.rb', line 26 def initialize(content:, limit:, offset:, next_page_id:, total_found:) @content = content @limit = limit @offset = offset @next_page_id = next_page_id @total_found = total_found end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/smartrecruiters/collection.rb', line 5 def content @content end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
5 6 7 |
# File 'lib/smartrecruiters/collection.rb', line 5 def limit @limit end |
#next_page_id ⇒ Object (readonly)
Returns the value of attribute next_page_id.
5 6 7 |
# File 'lib/smartrecruiters/collection.rb', line 5 def next_page_id @next_page_id end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/smartrecruiters/collection.rb', line 5 def offset @offset end |
#total_found ⇒ Object (readonly)
Returns the value of attribute total_found.
5 6 7 |
# File 'lib/smartrecruiters/collection.rb', line 5 def total_found @total_found end |
Class Method Details
.from_response(response, type:) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/smartrecruiters/collection.rb', line 7 def self.from_response(response, type:) body = response.body if body.is_a?(Array) new( content: body.map { |attrs| type.new(attrs) }, limit: nil, offset: nil, next_page_id: nil, total_found: nil ) else new( content: body['content'].map { |attrs| type.new(attrs) }, limit: body['limit'], offset: body['offset'], next_page_id: body['nextPageId'], total_found: body['totalFound'] ) end end |