Module: PyBossa::TaskRun

Defined in:
lib/pybossa-api/task_run.rb

Class Method Summary collapse

Class Method Details

.create(opts = {}) ⇒ Hash

Creates a task run.

Parameters:

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :app_id (Integer)

    the app ID to which this object belongs

  • :task_id (Integer)

    the task ID to which this object belongs

  • :timeout (Boolean)

    timeout for completing a task [not in use]

  • :calibration (Boolean)

    whether this is a calibration task [not in use]

  • :info (Hash)

    all other task run details

  • :api_key (String)

    an API key

Returns:

  • (Hash)

    a task run

See Also:



33
34
35
36
37
38
# File 'lib/pybossa-api/task_run.rb', line 33

def create(opts = {})
  if opts.has_key? :calibration
    opts[:calibration] = opts[:calibration] ? 1 : 0
  end
  PyBossa::API.create 'taskrun', opts
end

.delete(id, opts = {}) ⇒ Object

Deletes a task run.

Parameters:

  • id (Integer)

    a task run ID

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :api_key (String)

    an API key



57
58
59
# File 'lib/pybossa-api/task_run.rb', line 57

def delete(id, opts = {})
  PyBossa::API.destroy 'taskrun', id, opts
end

.get(id, opts = {}) ⇒ Hash

Returns a task run.

Parameters:

  • id (Integer)

    a task run ID

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :api_key (String)

    an API key

Returns:

  • (Hash)

    a task run



16
17
18
# File 'lib/pybossa-api/task_run.rb', line 16

def get(id, opts = {})
  PyBossa::API.retrieve 'taskrun', id, opts
end

.list(opts = {}) ⇒ Array

Returns a list of task runs.

Parameters:

  • opts (Hash) (defaults to: {})

    optional arguments

Options Hash (opts):

  • :limit (Integer)

    number of results to return [default 20]

  • :api_key (String)

    an API key

Returns:

  • (Array)

    a list of task runs



8
9
10
# File 'lib/pybossa-api/task_run.rb', line 8

def list(opts = {})
  PyBossa::API.many 'taskrun', opts
end

.update(id, opts = {}) ⇒ Object

Updates a task run.

Parameters:

  • id (Integer)

    a task run ID

See Also:

  • #create


45
46
47
48
49
50
# File 'lib/pybossa-api/task_run.rb', line 45

def update(id, opts = {})
  if opts.has_key? :calibration
    opts[:calibration] = opts[:calibration] ? 1 : 0
  end
  PyBossa::API.update 'taskrun', id, opts
end