Class: Flux::PT::Story
- Inherits:
-
Object
- Object
- Flux::PT::Story
- Extended by:
- Forwardable
- Defined in:
- lib/flux/pivotal_tracker.rb
Defined Under Namespace
Classes: Finders
Constant Summary collapse
- STATES_W_ESTIMATE =
%w(started finished delivered accepted rejected)
- STATES =
%w(unscheduled unstarted) + STATES_W_ESTIMATE
Class Method Summary collapse
Instance Method Summary collapse
- #estimate ⇒ Object (also: #est)
-
#initialize(story) ⇒ Story
constructor
A new instance of Story.
- #update(attrs) ⇒ Object
Constructor Details
#initialize(story) ⇒ Story
Returns a new instance of Story.
76 77 78 |
# File 'lib/flux/pivotal_tracker.rb', line 76 def initialize(story) @story = story end |
Class Method Details
.id_from_url(url) ⇒ Object
72 73 74 |
# File 'lib/flux/pivotal_tracker.rb', line 72 def self.id_from_url(url) URI.parse(url).path.split('/').last end |
Instance Method Details
#estimate ⇒ Object Also known as: est
80 81 82 |
# File 'lib/flux/pivotal_tracker.rb', line 80 def estimate (@story.estimate && @story.estimate < 0) ? nil : @story.estimate end |
#update(attrs) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/flux/pivotal_tracker.rb', line 86 def update(attrs) if attrs[:current_state] unless STATES.include?(attrs[:current_state]) raise TrackerError, "Invalid state: #{attrs[:current_state]}" end if STATES_W_ESTIMATE.include?(attrs[:current_state]) && ! estimate && ! attrs[:estimate] raise TrackerError, "Need an estimate for state `#{attrs[:current_state]}'." end end @story.update attrs end |