Class: Lotr::Sdk::Dataset
- Inherits:
-
Object
- Object
- Lotr::Sdk::Dataset
- Defined in:
- lib/lotr/sdk/dataset.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#error ⇒ Object
Returns the value of attribute error.
-
#meta ⇒ Object
Returns the value of attribute meta.
Instance Method Summary collapse
-
#initialize(response) ⇒ Dataset
constructor
A new instance of Dataset.
- #next_page_number ⇒ Object
Constructor Details
#initialize(response) ⇒ Dataset
Returns a new instance of Dataset.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/lotr/sdk/dataset.rb', line 6 def initialize(response) if response.code < 300 list = response.parse @data = list['docs'] @meta = { total_count: list['total'], current_page: list['page'], total_pages: list['pages'] } else @error = { error_code: response.code, error_message: response.to_s } end end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
5 6 7 |
# File 'lib/lotr/sdk/dataset.rb', line 5 def data @data end |
#error ⇒ Object
Returns the value of attribute error.
5 6 7 |
# File 'lib/lotr/sdk/dataset.rb', line 5 def error @error end |
#meta ⇒ Object
Returns the value of attribute meta.
5 6 7 |
# File 'lib/lotr/sdk/dataset.rb', line 5 def @meta end |
Instance Method Details
#next_page_number ⇒ Object
23 24 25 26 |
# File 'lib/lotr/sdk/dataset.rb', line 23 def next_page_number return nil if @error @meta[:current_page] < @meta[:total_pages] ? @meta[:current_page] + 1 : nil end |