Class: PivotalAPI::Story

Inherits:
Base
  • Object
show all
Defined in:
lib/pivotal-tracker-api/story.rb

Direct Known Subclasses

Stories

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#initialize, #to_json

Constructor Details

This class inherits a constructor from PivotalAPI::Base

Instance Attribute Details

#accepted_atObject

Returns the value of attribute accepted_at.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def accepted_at
  @accepted_at
end

#after_idObject

Returns the value of attribute after_id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def after_id
  @after_id
end

#before_idObject

Returns the value of attribute before_id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def before_id
  @before_id
end

#comment_idsObject

Returns the value of attribute comment_ids.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def comment_ids
  @comment_ids
end

#commentsObject

Returns the value of attribute comments.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def comments
  @comments
end

#created_atObject

Returns the value of attribute created_at.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def created_at
  @created_at
end

#current_stateObject

Returns the value of attribute current_state.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def current_state
  @current_state
end

#cycle_time_detailsObject

Returns the value of attribute cycle_time_details.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def cycle_time_details
  @cycle_time_details
end

#deadlineObject

Returns the value of attribute deadline.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def deadline
  @deadline
end

#descriptionObject

Returns the value of attribute description.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def description
  @description
end

#estimateObject

Returns the value of attribute estimate.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def estimate
  @estimate
end

#external_idObject

Returns the value of attribute external_id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def external_id
  @external_id
end

#follower_idsObject

Returns the value of attribute follower_ids.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def follower_ids
  @follower_ids
end

#followersObject

Returns the value of attribute followers.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def followers
  @followers
end

#has_attachmentsObject

Returns the value of attribute has_attachments.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def has_attachments
  @has_attachments
end

#idObject

Returns the value of attribute id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def id
  @id
end

#integration_idObject

Returns the value of attribute integration_id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def integration_id
  @integration_id
end

#kindObject

Returns the value of attribute kind.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def kind
  @kind
end

#label_idsObject

Returns the value of attribute label_ids.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def label_ids
  @label_ids
end

#labelsObject

Returns the value of attribute labels.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def labels
  @labels
end

#nameObject

Returns the value of attribute name.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def name
  @name
end

#owner_idsObject

Returns the value of attribute owner_ids.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def owner_ids
  @owner_ids
end

#ownersObject

Returns the value of attribute owners.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def owners
  @owners
end

#project_idObject

Returns the value of attribute project_id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def project_id
  @project_id
end

#requested_byObject

Returns the value of attribute requested_by.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def requested_by
  @requested_by
end

#requested_by_idObject

Returns the value of attribute requested_by_id.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def requested_by_id
  @requested_by_id
end

#story_typeObject

Returns the value of attribute story_type.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def story_type
  @story_type
end

#task_idsObject

Returns the value of attribute task_ids.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def task_ids
  @task_ids
end

#tasksObject

Returns the value of attribute tasks.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def tasks
  @tasks
end

#transitionsObject

Returns the value of attribute transitions.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def transitions
  @transitions
end

#updated_atObject

Returns the value of attribute updated_at.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def updated_at
  @updated_at
end

#urlObject

Returns the value of attribute url.



85
86
87
# File 'lib/pivotal-tracker-api/story.rb', line 85

def url
  @url
end

Class Method Details

.fieldsObject



93
94
95
96
97
98
99
100
# File 'lib/pivotal-tracker-api/story.rb', line 93

def self.fields
  ['url', 'name', 'description', 'story_type',
   'estimate', 'current_state', 'requested_by',
   'owners', 'labels', 'integration_id',
   'deadline', "comments(#{PivotalAPI::Comment.fields.join(',')})", 
   'tasks', 'transitions', 'followers', 'cycle_time_details',
   'accepted_at']
end

.from_json(json) ⇒ Object



102
103
104
# File 'lib/pivotal-tracker-api/story.rb', line 102

def self.from_json(json)
  parse_json_story(json)
end

Instance Method Details

#hoursObject



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/pivotal-tracker-api/story.rb', line 106

def hours
  return 0 if transitions.nil?
  duration_hrs = 0
  started = nil
  transitions.each do |transition|
    case transition.state
    when 'started'
      started = Time.parse(transition.occurred_at.to_s)
    when 'finished'
      duration_hrs += hours_between(started, Time.parse(transition.occurred_at.to_s)) if started
    end
  end
  
  if current_state == 'accepted'
    duration_hrs += hours_between(started, Time.parse(accepted_at.to_s))
  elsif current_state != 'accepted' && started
    duration_hrs += hours_between(started, Time.now)
  end
  
  duration_hrs
end

#overdue?Boolean

Returns:

  • (Boolean)


128
129
130
# File 'lib/pivotal-tracker-api/story.rb', line 128

def overdue?
  hours >= estimate
end