Class: Rallycat::Cat

Inherits:
Object
  • Object
show all
Defined in:
lib/rallycat/cat.rb

Instance Method Summary collapse

Constructor Details

#initialize(rally_api) ⇒ Cat

Returns a new instance of Cat.



6
7
8
# File 'lib/rallycat/cat.rb', line 6

def initialize(rally_api)
  @rally_api = rally_api
end

Instance Method Details

#story(story_number) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rallycat/cat.rb', line 10

def story(story_number)
  story_type = story_number.start_with?('US') ? :hierarchical_requirement : :defect

  results = @rally_api.find(story_type, :fetch => true) do
    equal :formatted_id, story_number
  end

  if results.total_result_count == 0
    raise StoryNotFound, "Story (#{ story_number }) does not exist."
  end

  consolidate_newlines parse_story(results.first)
end