Class: Asana::Workspace
- Inherits:
-
Object
- Object
- Asana::Workspace
- 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.
Class Method Summary collapse
-
.find(name) ⇒ Object
search a workspace by name.
Instance Method Summary collapse
-
#initialize(hash) ⇒ Workspace
constructor
A new instance of Workspace.
-
#projects ⇒ Object
get all projects associated with a workspace.
-
#tasks ⇒ Object
get tasks assigned to me within this workspace.
-
#users ⇒ Object
get all users in the workspace.
Constructor Details
#initialize(hash) ⇒ Workspace
Returns a new instance of Workspace.
320 321 322 323 |
# File 'lib/asana-client.rb', line 320 def initialize(hash) self.id = hash[:id] || 0 self.name = hash[:name] || "" end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
318 319 320 |
# File 'lib/asana-client.rb', line 318 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
318 319 320 |
# File 'lib/asana-client.rb', line 318 def name @name end |
Class Method Details
.find(name) ⇒ Object
search a workspace by name
326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/asana-client.rb', line 326 def self.find(name) # check if any workspace contains the given name, and return first hit name.downcase! Asana.workspaces.each do |workspace| if workspace.name.downcase.include? name return workspace end end nil end |
Instance Method Details
#projects ⇒ Object
get all projects associated with a workspace
339 340 341 342 343 344 345 346 347 348 |
# File 'lib/asana-client.rb', line 339 def projects project_objects = Asana.get "projects?workspace=#{self.id}" list = [] project_objects["data"].each do |project| list.push Project.new :id => project["id"], :name => project["name"], :workspace => self end list end |
#tasks ⇒ Object
get tasks assigned to me within this workspace
351 352 353 354 355 356 357 358 359 360 361 |
# File 'lib/asana-client.rb', line 351 def tasks task_objects = Asana.get "tasks?workspace=#{self.id}&assignee=me" list = [] task_objects["data"].each do |task| list.push Task.new :id => task["id"], :name => task["name"], :workspace => self end list end |
#users ⇒ Object
get all users in the workspace
364 365 366 367 368 369 370 371 372 373 |
# File 'lib/asana-client.rb', line 364 def users user_objects = Asana.get "workspaces/#{self.id}/users" list = [] user_objects["data"].each do |user| list.push User.new :id => user["id"], :name => user["name"] end list end |