Class: Todoist::Project
- Inherits:
-
Object
- Object
- Todoist::Project
- Defined in:
- lib/todoist/project.rb
Overview
Project
A todoist project.
Instance Attribute Summary collapse
-
#collapsed ⇒ Object
readonly
Returns the value of attribute collapsed.
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#indent ⇒ Object
readonly
Returns the value of attribute indent.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#order ⇒ Object
readonly
Returns the value of attribute order.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Class Method Summary collapse
-
.all ⇒ Array
Get all projects.
-
.get(id) ⇒ Todoist::Project
Get a project.
Instance Method Summary collapse
-
#add_task(content, opts = {}) ⇒ Todoist::Task
Add task.
- #collapsed? ⇒ Boolean
-
#completed_tasks ⇒ Array
Get completed tasks for the project.
-
#initialize(name, parameters = {}) ⇒ Todoist::Project
constructor
Create a new project.
- #inspect ⇒ Object
-
#task_count ⇒ Integer
The task count.
-
#tasks ⇒ Array
Get uncompleted tasks for the project.
- #to_i ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(name, parameters = {}) ⇒ Todoist::Project
Create a new project
Creates a new Todoist project.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/todoist/project.rb', line 45 def initialize(name, parameters={}) @name = name @id = parameters['id'] @user_id = parameters['user_id'] @color = parameters['color'] @collapsed = parameters['collapsed'] @order = parameters['item_order'] @count = parameters['cache_count'] @indent = parameters['indent'] end |
Instance Attribute Details
#collapsed ⇒ Object (readonly)
Returns the value of attribute collapsed.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def collapsed @collapsed end |
#color ⇒ Object (readonly)
Returns the value of attribute color.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def color @color end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def id @id end |
#indent ⇒ Object (readonly)
Returns the value of attribute indent.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def indent @indent end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def name @name end |
#order ⇒ Object (readonly)
Returns the value of attribute order.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def order @order end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
7 8 9 |
# File 'lib/todoist/project.rb', line 7 def user_id @user_id end |
Class Method Details
.all ⇒ Array
Get all projects
Fetches all the user’s todist projects.
15 16 17 18 19 20 21 |
# File 'lib/todoist/project.rb', line 15 def self.all projects = [] Base.get('/getProjects').each do |project| projects << new_from_api_request(project) end projects end |
.get(id) ⇒ Todoist::Project
Get a project
Fetches a todoist project
31 32 33 |
# File 'lib/todoist/project.rb', line 31 def self.get(id) new_from_api_request(get_project(id)) end |
Instance Method Details
#add_task(content, opts = {}) ⇒ Todoist::Task
Add task
Adds a task to the project.
110 111 112 |
# File 'lib/todoist/project.rb', line 110 def add_task(content, opts={}) Task.new(content, self, opts).save end |
#collapsed? ⇒ Boolean
69 70 71 |
# File 'lib/todoist/project.rb', line 69 def collapsed? (collapsed == 1) ? true : false end |
#completed_tasks ⇒ Array
Get completed tasks for the project
96 97 98 |
# File 'lib/todoist/project.rb', line 96 def completed_tasks Task.completed(self) end |
#inspect ⇒ Object
65 66 67 |
# File 'lib/todoist/project.rb', line 65 def inspect "<Project:#{name}:#{id}:#{task_count}:user_id=#{user_id} color='#{color}' collapsed=#{collapsed?} order=#{order} indent=#{indent}>" end |
#task_count ⇒ Integer
The task count
The number of tasks a project has, according to its cache_count when it was fetched
80 81 82 |
# File 'lib/todoist/project.rb', line 80 def task_count @count end |
#tasks ⇒ Array
Get uncompleted tasks for the project
88 89 90 |
# File 'lib/todoist/project.rb', line 88 def tasks Task.uncompleted(self) end |
#to_i ⇒ Object
61 62 63 |
# File 'lib/todoist/project.rb', line 61 def to_i id end |
#to_s ⇒ Object
57 58 59 |
# File 'lib/todoist/project.rb', line 57 def to_s "#{name}" end |