Class: RMC::Tasks

Inherits:
Object
  • Object
show all
Defined in:
lib/rmc/tasks.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ Tasks

Returns a new instance of Tasks.

[View source]

7
8
9
# File 'lib/rmc/tasks.rb', line 7

def initialize(connection)
  @connection = connection
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.


5
6
7
# File 'lib/rmc/tasks.rb', line 5

def connection
  @connection
end

Instance Method Details

#list_tasks(query = nil) ⇒ Object

[View source]

11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rmc/tasks.rb', line 11

def list_tasks(query=nil)
  @connection.version = 2
  response = @connection.request(
      url: "/tasks#{query ? "?query=\"#{query}\"" : ''}"
  )

  tasks = []
  response['tasks'].each do |_data|
    tasks << RMC::Item::Task.new(@connection, _data)
  end

  tasks
end