Class: Artisan::Stories::PertCalculator
- Inherits:
-
Object
- Object
- Artisan::Stories::PertCalculator
- Defined in:
- lib/artisan/stories/pert_calculator.rb
Instance Attribute Summary collapse
-
#estimate_mode ⇒ Object
readonly
Returns the value of attribute estimate_mode.
-
#story ⇒ Object
readonly
Returns the value of attribute story.
Instance Method Summary collapse
- #estimate ⇒ Object
-
#initialize(story, estimate_mode = "stddev") ⇒ PertCalculator
constructor
A new instance of PertCalculator.
- #standard_deviation ⇒ Object
- #variance ⇒ Object
- #weighted_mean ⇒ Object
Constructor Details
#initialize(story, estimate_mode = "stddev") ⇒ PertCalculator
Returns a new instance of PertCalculator.
12 13 14 15 |
# File 'lib/artisan/stories/pert_calculator.rb', line 12 def initialize(story, estimate_mode = "stddev") @story = story @estimate_mode = estimate_mode end |
Instance Attribute Details
#estimate_mode ⇒ Object (readonly)
Returns the value of attribute estimate_mode.
10 11 12 |
# File 'lib/artisan/stories/pert_calculator.rb', line 10 def estimate_mode @estimate_mode end |
#story ⇒ Object (readonly)
Returns the value of attribute story.
10 11 12 |
# File 'lib/artisan/stories/pert_calculator.rb', line 10 def story @story end |
Instance Method Details
#estimate ⇒ Object
29 30 31 32 33 |
# File 'lib/artisan/stories/pert_calculator.rb', line 29 def estimate mean = unrounded_weighted_mean mean += unrounded_standard_deviation * 2 if @estimate_mode.to_s != "mean" return mean.round_to(0.25) end |
#standard_deviation ⇒ Object
21 22 23 |
# File 'lib/artisan/stories/pert_calculator.rb', line 21 def standard_deviation unrounded_standard_deviation.round(2) end |
#variance ⇒ Object
25 26 27 |
# File 'lib/artisan/stories/pert_calculator.rb', line 25 def variance unrounded_variance.round(2) end |
#weighted_mean ⇒ Object
17 18 19 |
# File 'lib/artisan/stories/pert_calculator.rb', line 17 def weighted_mean unrounded_weighted_mean.round_to(0.25) end |