Class: Wunderlist::List
- Inherits:
-
FilterableList
- Object
- FilterableList
- Wunderlist::List
- Defined in:
- lib/wunderlist/list.rb
Overview
A List is a FilterableList which can be synchronized with an API object
Instance Attribute Summary collapse
-
#api ⇒ Object
Reference to the associated API object.
-
#id ⇒ Object
ID of the list on the Wunderlist server.
-
#inbox ⇒ Object
Value which determines whether this list is a INBOX or or not.
-
#name ⇒ Object
Name of the list.
-
#shared ⇒ Object
true, if list is shared, otherwise false.
Instance Method Summary collapse
-
#create_task(name, date = nil) ⇒ Object
Create task with specified name and date.
-
#destroy(api = nil) ⇒ Object
Destroy list with api.
-
#flush ⇒ Object
Remove tasks cache.
-
#initialize(name = nil, inbox = nil, api = nil) ⇒ List
constructor
A new instance of List.
-
#save(api = nil) ⇒ Object
Save list with api.
-
#tasks ⇒ Object
Get all tasks.
- #to_s ⇒ Object
Methods inherited from FilterableList
#done, #not_done, #not_overdue, #not_priority, #overdue, #priority, #today
Constructor Details
#initialize(name = nil, inbox = nil, api = nil) ⇒ List
Returns a new instance of List.
128 129 130 131 132 |
# File 'lib/wunderlist/list.rb', line 128 def initialize(name = nil, inbox = nil, api = nil) @name = name @inbox = inbox @api = api end |
Instance Attribute Details
#api ⇒ Object
Reference to the associated API object. Necessary for many methods.
126 127 128 |
# File 'lib/wunderlist/list.rb', line 126 def api @api end |
#id ⇒ Object
ID of the list on the Wunderlist server
110 111 112 |
# File 'lib/wunderlist/list.rb', line 110 def id @id end |
#inbox ⇒ Object
Value which determines whether this list is a INBOX or or not
118 119 120 |
# File 'lib/wunderlist/list.rb', line 118 def inbox @inbox end |
#name ⇒ Object
Name of the list
114 115 116 |
# File 'lib/wunderlist/list.rb', line 114 def name @name end |
#shared ⇒ Object
true, if list is shared, otherwise false
122 123 124 |
# File 'lib/wunderlist/list.rb', line 122 def shared @shared end |
Instance Method Details
#create_task(name, date = nil) ⇒ Object
Create task with specified name and date
143 144 145 |
# File 'lib/wunderlist/list.rb', line 143 def create_task(name, date = nil) Wunderlist::Task.new(name, date, self, @api).save end |
#destroy(api = nil) ⇒ Object
Destroy list with api
156 157 158 159 |
# File 'lib/wunderlist/list.rb', line 156 def destroy(api = nil) @api ||= api @api.destroy(self) end |
#flush ⇒ Object
Remove tasks cache
163 164 165 |
# File 'lib/wunderlist/list.rb', line 163 def flush @tasks = nil end |
#save(api = nil) ⇒ Object
Save list with api
149 150 151 152 |
# File 'lib/wunderlist/list.rb', line 149 def save(api = nil) @api ||= api @api.save(self) end |
#tasks ⇒ Object
Get all tasks
136 137 138 139 |
# File 'lib/wunderlist/list.rb', line 136 def tasks @tasks = @api.tasks self if @tasks == nil @tasks end |
#to_s ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/wunderlist/list.rb', line 167 def to_s lines = [] lines << "[List]#{inbox ? " [INBOX]" : ""} #{name} - #{tasks.count != 1 ? (tasks.count.to_s + " tasks") : tasks.count.to_s + " task"}" tasks.each do |task| lines << " #{task}" end lines.join "\n" end |