class Yapt::Story

Attributes

raw_story[R]

Public Class Methods

base_site_url() click to toggle source
# File lib/yapt/story.rb, line 57
def self.base_site_url
  "https://www.pivotaltracker.com/projects/#{Yapt.project_id}"
end
bottom_of_backlog() click to toggle source
# File lib/yapt/story.rb, line 37
def self.bottom_of_backlog
  find(["state:unstarted"]).last
end
bottom_of_icebox() click to toggle source
# File lib/yapt/story.rb, line 41
def self.bottom_of_icebox
  find(["state:unscheduled"]).last
end
find(options = ["limit=5"]) click to toggle source
# File lib/yapt/story.rb, line 3
def self.find(options = ["limit=5"])
  return find_one(options) if options.kind_of?(String)
  params = Filter.parse(options)
  results = Request.new("stories", params, :get).result
  results.collect {|r| new(r) }
end
find_by_id(id) click to toggle source
# File lib/yapt/story.rb, line 25
def self.find_by_id(id)
  new(Request.new("stories/#{id}", {}, :get).result)
end
find_one(id) click to toggle source
# File lib/yapt/story.rb, line 10
def self.find_one(id)
  case id
  when /\A\d+\Z/  then find_by_id(id)
  when 'tback'    then top_of_backlog
  when 'tbacklog' then top_of_backlog
  when 'tice'     then top_of_icebox
  when 'ticebox'  then top_of_icebox

  when 'bback'    then bottom_of_backlog
  when 'bbacklog' then bottom_of_backlog
  when 'bice'     then bottom_of_icebox
  when 'bicebox'  then bottom_of_icebox
  end
end
images_url(id) click to toggle source
# File lib/yapt/story.rb, line 53
def self.images_url(id)
  "#{just_url(id)}/images"
end
just_url(id) click to toggle source
# File lib/yapt/story.rb, line 45
def self.just_url(id)
  if id
    "#{base_site_url}/stories/#{id}"
  else
    base_site_url
  end
end
new(raw_story) click to toggle source
# File lib/yapt/story.rb, line 62
def initialize(raw_story)
  @raw_story = raw_story
end
top_of_backlog() click to toggle source
# File lib/yapt/story.rb, line 29
def self.top_of_backlog
  find(["state:unstarted", "limit:1"]).first
end
top_of_icebox() click to toggle source
# File lib/yapt/story.rb, line 33
def self.top_of_icebox
  find(["state:unscheduled", "limit:1"]).first
end

Public Instance Methods

comments() click to toggle source
# File lib/yapt/story.rb, line 78
def comments
  @comments ||= Comment.find(id)
end
created_at_display() click to toggle source
# File lib/yapt/story.rb, line 94
def created_at_display
  "Created: #{time_display(created_at)}"
end
has_image?() click to toggle source
# File lib/yapt/story.rb, line 74
def has_image?
  Request.new("stories/", {filter: "id:#{id} has:attachment"}, :get).result.any?
end
owner_initials() click to toggle source
# File lib/yapt/story.rb, line 82
def owner_initials
  if owned_by_id
    "Owner: #{Member.find(owned_by_id).initials}"
  else
    "No owner"
  end
end
requester_initials() click to toggle source
# File lib/yapt/story.rb, line 90
def requester_initials
  "Requester: #{Member.find(requested_by_id).initials}"
end
time_display(time) click to toggle source
# File lib/yapt/story.rb, line 102
def time_display(time)
  Time.parse(time).strftime("%a %d%b %I:%M")
end
updated_at_display() click to toggle source
# File lib/yapt/story.rb, line 98
def updated_at_display
  "Updated: #{time_display(updated_at)}"
end