Class: HabiticaClient::Tasks

Inherits:
ApiBase
  • Object
show all
Includes:
Enumerable, Status, Types
Defined in:
lib/habitica_client/tasks.rb,
lib/habitica_client/tasks/types.rb,
lib/habitica_client/tasks/status.rb

Overview

An enumerable object of all the user's tasks.

Also contains the endpoint for creating new tasks.

Defined Under Namespace

Modules: Status, Types

Instance Attribute Summary

Attributes inherited from ApiBase

#client

Instance Method Summary collapse

Methods included from Status

#completed, #uncompleted

Methods included from Types

#by_type, #dailies, #habits, #todos

Methods inherited from ApiBase

#data, #endpoint, endpoint, #initialize

Constructor Details

This class inherits a constructor from HabiticaClient::ApiBase

Instance Method Details

#create(attributes = {}) ⇒ Object

Create a new task (and save it to habitrpg.com)

Parameters:

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

    a hash of attributes for the new task.



28
29
30
# File 'lib/habitica_client/tasks.rb', line 28

def create(attributes = {})
  Task.new(client, attributes).save
end

#eachObject

Iterate over user tasks



19
20
21
22
23
# File 'lib/habitica_client/tasks.rb', line 19

def each
  data.each do |task|
    yield Task.parse(client, task)
  end
end