Class: Artisan::Stories::PertCalculator

Inherits:
Object
  • Object
show all
Defined in:
lib/artisan/stories/pert_calculator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_modeObject (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

#storyObject (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

#estimateObject



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_deviationObject



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

def standard_deviation
  unrounded_standard_deviation.round(2)
end

#varianceObject



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

def variance
  unrounded_variance.round(2)
end

#weighted_meanObject



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

def weighted_mean
  unrounded_weighted_mean.round_to(0.25)
end