Class: Asana::Task
- Inherits:
-
Object
- Object
- Asana::Task
- Defined in:
- lib/asana-client.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#project ⇒ Object
Returns the value of attribute project.
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Class Method Summary collapse
-
.comment(id, text) ⇒ Object
comment on a task.
-
.create(workspace, name, assignee = nil, due = nil) ⇒ Object
create a new task on the server.
-
.finish(id) ⇒ Object
finish a task.
Instance Method Summary collapse
-
#comment(text) ⇒ Object
comment on the current task.
-
#finish ⇒ Object
finish the current task.
-
#initialize(hash) ⇒ Task
constructor
A new instance of Task.
- #to_s ⇒ Object
Constructor Details
#initialize(hash) ⇒ Task
Returns a new instance of Task.
225 226 227 228 229 230 |
# File 'lib/asana-client.rb', line 225 def initialize(hash) self.id = hash[:id] || 0 self.name = hash[:name] || "" self.workspace = hash[:workspace] || nil self.project = hash[:project] || nil end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
223 224 225 |
# File 'lib/asana-client.rb', line 223 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
223 224 225 |
# File 'lib/asana-client.rb', line 223 def name @name end |
#project ⇒ Object
Returns the value of attribute project.
223 224 225 |
# File 'lib/asana-client.rb', line 223 def project @project end |
#workspace ⇒ Object
Returns the value of attribute workspace.
223 224 225 |
# File 'lib/asana-client.rb', line 223 def workspace @workspace end |
Class Method Details
.comment(id, text) ⇒ Object
comment on a task
263 264 265 |
# File 'lib/asana-client.rb', line 263 def self.comment(id, text) Asana.post "tasks/#{id}/stories", { "text" => text } end |
.create(workspace, name, assignee = nil, due = nil) ⇒ Object
create a new task on the server
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
# File 'lib/asana-client.rb', line 233 def self.create(workspace, name, assignee = nil, due = nil) # if given string for workspace, convert to object if workspace.is_a? String workspace = Asana::Workspace.find workspace end abort "Workspace not found" unless workspace # if assignee was given, get user if !assignee.nil? assignee = Asana::User.find workspace, assignee abort "Assignee not found" unless assignee end # add task to workspace params = { "workspace" => workspace.id, "name" => name, "assignee" => (assignee.nil?) ? "me" : assignee.id } # attach due date if given if !due.nil? params["due_on"] = due end # add task to workspace Asana.post "tasks", params end |
Instance Method Details
#comment(text) ⇒ Object
comment on the current task
268 269 270 |
# File 'lib/asana-client.rb', line 268 def comment(text) self.comment(self.id, text) end |
#finish ⇒ Object
finish the current task
278 279 280 |
# File 'lib/asana-client.rb', line 278 def finish self.finish(self.id) end |
#to_s ⇒ Object
282 283 284 |
# File 'lib/asana-client.rb', line 282 def to_s "(#{self.id}) #{self.name}" end |