Module: PyBossa::Task

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

Class Method Summary collapse

Class Method Details

.create(opts = {}) ⇒ Hash

Creates a task.

Parameters:

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

    optional arguments

Options Hash (opts):

  • :app_id (Integer)

    the app ID to which this object belongs

  • :state (String)

    one of:

    • "all": Default state
    • "in_progress": A user is running the task
    • "pending": The task is completed but requires validation
    • "valid": The task is completed and valid
    • "invalid": The task is completed and invalid
    • "error": The task has an error
  • :quorum (Integer)

    number of users who should do this task [not in use]

  • :calibration (Boolean)

    whether this is a calibration task [not in use]

  • :priority_0 (Float)

    between 0 (low) and 1 (high) [not in use]

  • :info (Hash)

    all other task details

  • :api_key (String)

    an API key

Returns:

  • (Hash)

    a task

See Also:



39
40
41
42
43
44
# File 'lib/pybossa-api/task.rb', line 39

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

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

Deletes a task.

Parameters:

  • id (Integer)

    a task ID

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

    optional arguments

Options Hash (opts):

  • :api_key (String)

    an API key



63
64
65
# File 'lib/pybossa-api/task.rb', line 63

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

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

Returns a task.

Parameters:

  • id (Integer)

    a task ID

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

    optional arguments

Options Hash (opts):

  • :api_key (String)

    an API key

Returns:

  • (Hash)

    a task



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

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

.list(opts = {}) ⇒ Array

Returns a list of tasks.

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 tasks



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

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

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

Updates a task.

Parameters:

  • id (Integer)

    a task ID

See Also:

  • #create


51
52
53
54
55
56
# File 'lib/pybossa-api/task.rb', line 51

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