Class: Nzbn::Models::SearchResponse
- Defined in:
- lib/nzbn/models/search_response.rb
Overview
Paginated search response
Instance Attribute Summary collapse
-
#items ⇒ Object
Returns the value of attribute items.
-
#links ⇒ Object
Returns the value of attribute links.
-
#page ⇒ Object
Returns the value of attribute page.
-
#page_size ⇒ Object
Returns the value of attribute page_size.
-
#sort_by ⇒ Object
Returns the value of attribute sort_by.
-
#sort_order ⇒ Object
Returns the value of attribute sort_order.
-
#total_items ⇒ Object
Returns the value of attribute total_items.
Instance Method Summary collapse
- #count ⇒ Object (also: #size, #length)
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
- #first ⇒ Object
-
#initialize(attributes = {}, item_class: nil) ⇒ SearchResponse
constructor
A new instance of SearchResponse.
- #last ⇒ Object
- #map(&block) ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(attributes = {}, item_class: nil) ⇒ SearchResponse
Returns a new instance of SearchResponse.
9 10 11 12 |
# File 'lib/nzbn/models/search_response.rb', line 9 def initialize(attributes = {}, item_class: nil) super(attributes) @items = parse_items(attributes['items'], item_class) if item_class end |
Instance Attribute Details
#items ⇒ Object
Returns the value of attribute items.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def items @items end |
#links ⇒ Object
Returns the value of attribute links.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def links @links end |
#page ⇒ Object
Returns the value of attribute page.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def page @page end |
#page_size ⇒ Object
Returns the value of attribute page_size.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def page_size @page_size end |
#sort_by ⇒ Object
Returns the value of attribute sort_by.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def sort_by @sort_by end |
#sort_order ⇒ Object
Returns the value of attribute sort_order.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def sort_order @sort_order end |
#total_items ⇒ Object
Returns the value of attribute total_items.
7 8 9 |
# File 'lib/nzbn/models/search_response.rb', line 7 def total_items @total_items end |
Instance Method Details
#count ⇒ Object Also known as: size, length
34 35 36 |
# File 'lib/nzbn/models/search_response.rb', line 34 def count items&.length || 0 end |
#each(&block) ⇒ Object
14 15 16 |
# File 'lib/nzbn/models/search_response.rb', line 14 def each(&block) items.each(&block) end |
#empty? ⇒ Boolean
30 31 32 |
# File 'lib/nzbn/models/search_response.rb', line 30 def empty? items.nil? || items.empty? end |
#first ⇒ Object
22 23 24 |
# File 'lib/nzbn/models/search_response.rb', line 22 def first items.first end |
#last ⇒ Object
26 27 28 |
# File 'lib/nzbn/models/search_response.rb', line 26 def last items.last end |
#map(&block) ⇒ Object
18 19 20 |
# File 'lib/nzbn/models/search_response.rb', line 18 def map(&block) items.map(&block) end |