Class: Trajectory::Stories

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/trajectory/domain/stories.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*stories) ⇒ Stories

Creates a new collection of Trajectory::Story

Parameters:



10
11
12
# File 'lib/trajectory/domain/stories.rb', line 10

def initialize(*stories)
  super(stories)
end

Class Method Details

.from_json(project, json_attributes) ⇒ Object

Create a new collection of Trajectory::Story from a JSON array of attributes from trajectory API

Parameters:

  • project (Project)

    the project the stories belongs to

  • json_attributes (Hash)

    the hash of attributes of each story of the collection



18
19
20
21
22
23
# File 'lib/trajectory/domain/stories.rb', line 18

def self.from_json(project, json_attributes)
  new(*json_attributes.map do |attributes|
    attributes = attributes.symbolize_keys!.merge({project_id: project.id})
    Story.new(attributes)
  end)
end

Instance Method Details

#in_iteration(iteration) ⇒ Stories

Returns stories of the collection that are in the given iteration

Parameters:

Returns:

  • (Stories)

    stories collection in iteration



50
51
52
53
54
# File 'lib/trajectory/domain/stories.rb', line 50

def in_iteration(iteration)
  stories.select do |story|
    story.in_iteration?(iteration)
  end
end

#not_completedStories

Returns not completed stories of the collection

Returns:

  • (Stories)

    not completed stories collection



42
43
44
# File 'lib/trajectory/domain/stories.rb', line 42

def not_completed
  stories.reject(&:completed?)
end

#startedStories

Returns started stories of the collection

Returns:

  • (Stories)

    started stories collection



28
29
30
# File 'lib/trajectory/domain/stories.rb', line 28

def started
  stories.select(&:started?)
end

#unstartedStories

Returns unstarted stories of the collection

Returns:

  • (Stories)

    unstarted stories collection



35
36
37
# File 'lib/trajectory/domain/stories.rb', line 35

def unstarted
  stories.select(&:unstarted?)
end