Class: Asana::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/asana-client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Project

Returns a new instance of Project.



182
183
184
185
186
# File 'lib/asana-client.rb', line 182

def initialize(hash)
    self.id = hash[:id] || 0
    self.name = hash[:name] || ""
    self.workspace = hash[:workspace] || nil
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



180
181
182
# File 'lib/asana-client.rb', line 180

def id
  @id
end

#nameObject

Returns the value of attribute name.



180
181
182
# File 'lib/asana-client.rb', line 180

def name
  @name
end

#workspaceObject

Returns the value of attribute workspace.



180
181
182
# File 'lib/asana-client.rb', line 180

def workspace
  @workspace
end

Class Method Details

.find(workspace, name) ⇒ Object

search for a project within a workspace



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
# File 'lib/asana-client.rb', line 189

def self.find(workspace, name)
    # if given string for workspace, convert to object
    if workspace.is_a? String
        workspace = Asana::Workspace.find workspace 
    end

    # check if any workspace contains the given name, and return first hit
    name.downcase!
    if workspace
        workspace.projects.each do |project|
            if project.name.downcase.include? name
                return project
            end
        end
    end

    nil
end

Instance Method Details

#tasksObject

get all tasks associated with the current project



209
210
211
212
213
214
215
216
217
218
219
# File 'lib/asana-client.rb', line 209

def tasks
    task_objects = Asana.get "tasks?project=#{self.id}"
    list = []

    task_objects["data"].each do |task|
        list.push Task.new :id => task["id"], :name => task["name"],
            :workspace => self.workspace, :project => self
    end

    list
end