Class: Central::Support::Iteration
- Inherits:
-
Array
- Object
- Array
- Central::Support::Iteration
- Defined in:
- lib/central/support/iteration.rb
Overview
mimics the iteration.js counterpart
Instance Attribute Summary collapse
-
#maximum_points ⇒ Object
readonly
Returns the value of attribute maximum_points.
-
#number ⇒ Object
readonly
Returns the value of attribute number.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #available_points ⇒ Object
- #can_take_story?(story) ⇒ Boolean
- #details ⇒ Object
-
#initialize(service, iteration_number, maximum_points = nil) ⇒ Iteration
constructor
A new instance of Iteration.
- #overflows_by ⇒ Object
- #points ⇒ Object
Constructor Details
#initialize(service, iteration_number, maximum_points = nil) ⇒ Iteration
Returns a new instance of Iteration.
7 8 9 10 11 12 13 |
# File 'lib/central/support/iteration.rb', line 7 def initialize(service, iteration_number, maximum_points = nil) @service = service @number = iteration_number @maximum_points = maximum_points @is_full = false super([]) end |
Instance Attribute Details
#maximum_points ⇒ Object (readonly)
Returns the value of attribute maximum_points.
5 6 7 |
# File 'lib/central/support/iteration.rb', line 5 def maximum_points @maximum_points end |
#number ⇒ Object (readonly)
Returns the value of attribute number.
5 6 7 |
# File 'lib/central/support/iteration.rb', line 5 def number @number end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
5 6 7 |
# File 'lib/central/support/iteration.rb', line 5 def start_date @start_date end |
Instance Method Details
#available_points ⇒ Object
19 20 21 |
# File 'lib/central/support/iteration.rb', line 19 def available_points maximum_points - points end |
#can_take_story?(story) ⇒ Boolean
23 24 25 26 27 28 29 30 31 |
# File 'lib/central/support/iteration.rb', line 23 def can_take_story?(story) return true if %w(started finished delivered accepted rejected).include? story.state return false if @is_full return true if points == 0 return true if story.story_type != 'feature' @is_full = (story.estimate || 0) > available_points !@is_full end |
#details ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/central/support/iteration.rb', line 42 def details { points: self.reduce(0) { |total, story| total + (story.estimate || 0) }, count: self.size, non_estimable: self.select { |story| !Story::ESTIMABLE_TYPES.include?(story.story_type) }.size } end |
#overflows_by ⇒ Object
33 34 35 36 |
# File 'lib/central/support/iteration.rb', line 33 def overflows_by difference = points - maximum_points difference < 0 ? 0 : difference end |
#points ⇒ Object
15 16 17 |
# File 'lib/central/support/iteration.rb', line 15 def points self.reduce(0) { |total, story| total + ( story.estimate || 0 ) } end |