class PivotalTracker::Note
Attributes
project_id[RW]
story_id[RW]
Public Class Methods
all(story, options={})
click to toggle source
# File lib/pivotal-tracker/note.rb, line 6 def all(story, options={}) notes = parse(Client.connection["/projects/#{story.project_id}/stories/#{story.id}/notes"].get) notes.each { |n| n.project_id, n.story_id = story.project_id, story.id } return notes end
new(attributes={})
click to toggle source
# File lib/pivotal-tracker/note.rb, line 21 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/note.rb, line 31 def create response = Client.connection["/projects/#{project_id}/stories/#{story_id}/notes"].post(self.to_xml, :content_type => 'application/xml') return Note.parse(response) end
Protected Instance Methods
to_xml()
click to toggle source
Pivotal Tracker API doesn't seem to support updating or deleting notes at this time.
# File lib/pivotal-tracker/note.rb, line 40 def to_xml builder = Nokogiri::XML::Builder.new do |xml| xml.note { #xml.author "#{author}" xml.text_ "#{text}" xml.noted_at "#{noted_at}" } end return builder.to_xml end
update_attributes(attrs)
click to toggle source
# File lib/pivotal-tracker/note.rb, line 51 def update_attributes(attrs) attrs.each do |key, value| self.send("#{key}=", value.is_a?(Array) ? value.join(',') : value ) end end