class PivotalTracker::Task

Attributes

project_id[RW]
story_id[RW]

Public Class Methods

all(story, options={}) click to toggle source
# File lib/pivotal-tracker/task.rb, line 6
def all(story, options={})
  tasks = parse(Client.connection["/projects/#{story.project_id}/stories/#{story.id}/tasks"].get)
  tasks.each { |t| t.project_id, t.story_id = story.project_id, story.id }
  return tasks
end
new(attributes={}) click to toggle source
# File lib/pivotal-tracker/task.rb, line 22
def initialize(attributes={})
  if attributes[:owner]
    self.story = attributes.delete(:owner)
    self.project_id = self.story.project_id
    self.story_id = self.story.id
  end

  update_attributes(attributes)
end

Public Instance Methods

create() click to toggle source
# File lib/pivotal-tracker/task.rb, line 32
def create
  response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks"].post(self.to_xml, :content_type => 'application/xml')
  return Task.parse(response)
end
delete() click to toggle source
# File lib/pivotal-tracker/task.rb, line 43
def delete
  Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks/#{id}"].delete
end
update(attr = {}) click to toggle source
# File lib/pivotal-tracker/task.rb, line 37
def update(attr = {})
  update_attributes(attr)
  response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks/#{id}"].put(self.to_xml, :content_type => 'application/xml')
  return Task.parse(response)
end

Protected Instance Methods

to_xml() click to toggle source
# File lib/pivotal-tracker/task.rb, line 49
def to_xml
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.task {
      xml.description "#{description}"
      # xml.position "#{position}"
      xml.complete "#{complete}"
    }
  end
  return builder.to_xml
end
update_attributes(attrs) click to toggle source
# File lib/pivotal-tracker/task.rb, line 60
def update_attributes(attrs)
  attrs.each do |key, value|
    self.send("#{key}=", value.is_a?(Array) ? value.join(',') : value )
  end
end