Class: Rallycat::Cat

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

Defined Under Namespace

Classes: StoryNotFound

Instance Method Summary collapse

Constructor Details

#initialize(rally_api) ⇒ Cat

Returns a new instance of Cat.



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

def initialize(rally_api)
  @rally_api = rally_api
end

Instance Method Details

#story(story_number) ⇒ Object



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

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