Class: Scale::Api::TaskList
- Inherits:
-
Object
- Object
- Scale::Api::TaskList
- Extended by:
- Forwardable
- Includes:
- Enumerable
- Defined in:
- lib/scale/api/task_list.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#docs ⇒ Object
Returns the value of attribute docs.
-
#has_more ⇒ Object
Returns the value of attribute has_more.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
- #has_more? ⇒ Boolean
-
#initialize(client: nil, docs: [], limit: 99, offset: 0, has_more: false, params: {}) ⇒ TaskList
constructor
A new instance of TaskList.
- #next_page ⇒ Object
- #page ⇒ Object
Constructor Details
#initialize(client: nil, docs: [], limit: 99, offset: 0, has_more: false, params: {}) ⇒ TaskList
Returns a new instance of TaskList.
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/scale/api/task_list.rb', line 11 def initialize(client: nil, docs: [], limit: 99, offset: 0, has_more: false, params: {}) self.client = client self.docs = docs.map do |doc| ::Scale::Api::Tasks::BaseTask.new(doc, client) end self.limit = limit self.offset = offset self.has_more = has_more self.params = params # Used to get next page end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
9 10 11 |
# File 'lib/scale/api/task_list.rb', line 9 def client @client end |
#docs ⇒ Object
Returns the value of attribute docs.
9 10 11 |
# File 'lib/scale/api/task_list.rb', line 9 def docs @docs end |
#has_more ⇒ Object
Returns the value of attribute has_more.
9 10 11 |
# File 'lib/scale/api/task_list.rb', line 9 def has_more @has_more end |
#limit ⇒ Object
Returns the value of attribute limit.
9 10 11 |
# File 'lib/scale/api/task_list.rb', line 9 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
9 10 11 |
# File 'lib/scale/api/task_list.rb', line 9 def offset @offset end |
#params ⇒ Object
Returns the value of attribute params.
9 10 11 |
# File 'lib/scale/api/task_list.rb', line 9 def params @params end |
Instance Method Details
#has_more? ⇒ Boolean
23 24 25 |
# File 'lib/scale/api/task_list.rb', line 23 def has_more? !!has_more end |
#next_page ⇒ Object
31 32 33 34 35 |
# File 'lib/scale/api/task_list.rb', line 31 def next_page next_page_params = params.dup params[:offset] = params[:limit] + params[:offset] Scale::Api::Tasks.new(client).list(params) end |
#page ⇒ Object
27 28 29 |
# File 'lib/scale/api/task_list.rb', line 27 def page (offset + (limit * 1)) / limit end |