Class: Artisan::Stories::StoryCollection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/artisan/stories/story_collection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stories = []) ⇒ StoryCollection

Returns a new instance of StoryCollection.



9
10
11
# File 'lib/artisan/stories/story_collection.rb', line 9

def initialize(stories = [])
  @stories = stories
end

Instance Attribute Details

#storiesObject (readonly) Also known as: all

Returns the value of attribute stories.



6
7
8
# File 'lib/artisan/stories/story_collection.rb', line 6

def stories
  @stories
end

Instance Method Details

#all_complete?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'lib/artisan/stories/story_collection.rb', line 53

def all_complete?
  all?(&:complete?)
end

#billableObject



13
14
15
# File 'lib/artisan/stories/story_collection.rb', line 13

def billable
  select {|story| !story.nonbillable?}
end

#billable_pointsObject



29
30
31
# File 'lib/artisan/stories/story_collection.rb', line 29

def billable_points
  sum_estimates(billable)
end

#billedObject



17
18
19
# File 'lib/artisan/stories/story_collection.rb', line 17

def billed
  select{|s| !s.nonbillable? && s.complete?}
end

#billed_pointsObject



33
34
35
# File 'lib/artisan/stories/story_collection.rb', line 33

def billed_points
  sum_estimates(billed)
end

#billed_points_by_craftsmanObject



37
38
39
40
# File 'lib/artisan/stories/story_collection.rb', line 37

def billed_points_by_craftsman
  totals = sum_estimates_by_craftsman(billed)
  totals.keys.collect { |craftsman| {craftsman: craftsman, points: totals[craftsman]} }
end

#completedObject



21
22
23
# File 'lib/artisan/stories/story_collection.rb', line 21

def completed
  select(&:complete?)
end

#completed_pointsObject



49
50
51
# File 'lib/artisan/stories/story_collection.rb', line 49

def completed_points
  sum_estimates(completed)
end

#each(&block) ⇒ Object



57
58
59
# File 'lib/artisan/stories/story_collection.rb', line 57

def each(&block)
  stories.each { |story| block.call(story) }
end

#estimated_pointsObject Also known as: points, total_points



42
43
44
# File 'lib/artisan/stories/story_collection.rb', line 42

def estimated_points
  sum_estimates(@stories)
end

#incompleteObject



25
26
27
# File 'lib/artisan/stories/story_collection.rb', line 25

def incomplete
  reject(&:complete?)
end