Module: EarnedValueCalculator
- Extended by:
- ActiveModel::Validations
- Defined in:
- lib/earned_value_calculator.rb,
lib/earned_value_calculator/version.rb,
lib/earned_value_calculator/validator.rb
Overview
This module represents a project metric with Earned Value Management.
Defined Under Namespace
Classes: Validator
Constant Summary collapse
- VERSION =
"0.1.6"
Class Attribute Summary collapse
-
.actual_cost ⇒ Object
Returns the value of attribute actual_cost.
-
.actual_cost_variance ⇒ Object
Returns the value of attribute actual_cost_variance.
-
.budget ⇒ Object
Returns the value of attribute budget.
-
.cost_performance_index ⇒ Object
Returns the value of attribute cost_performance_index.
-
.current_length ⇒ Object
Returns the value of attribute current_length.
-
.earned_value ⇒ Object
Returns the value of attribute earned_value.
-
.estimate_at_completion ⇒ Object
Returns the value of attribute estimate_at_completion.
-
.estimate_to_completion ⇒ Object
Returns the value of attribute estimate_to_completion.
-
.planned_value ⇒ Object
Returns the value of attribute planned_value.
-
.project_length ⇒ Object
Returns the value of attribute project_length.
-
.rate ⇒ Object
Returns the value of attribute rate.
-
.schedule_performance_index ⇒ Object
Returns the value of attribute schedule_performance_index.
-
.schedule_variance ⇒ Object
Returns the value of attribute schedule_variance.
-
.variance_at_completion ⇒ Object
Returns the value of attribute variance_at_completion.
Class Method Summary collapse
- .calculate_earned_values ⇒ Object
-
.call(start_date, end_date, current_date, budget, rate, actual_cost) ⇒ EarnedValueCalculator
The object.
Class Attribute Details
.actual_cost ⇒ Object
Returns the value of attribute actual_cost.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def actual_cost @actual_cost end |
.actual_cost_variance ⇒ Object
Returns the value of attribute actual_cost_variance.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def actual_cost_variance @actual_cost_variance end |
.budget ⇒ Object
Returns the value of attribute budget.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def budget @budget end |
.cost_performance_index ⇒ Object
Returns the value of attribute cost_performance_index.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def cost_performance_index @cost_performance_index end |
.current_length ⇒ Object
Returns the value of attribute current_length.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def current_length @current_length end |
.earned_value ⇒ Object
Returns the value of attribute earned_value.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def earned_value @earned_value end |
.estimate_at_completion ⇒ Object
Returns the value of attribute estimate_at_completion.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def estimate_at_completion @estimate_at_completion end |
.estimate_to_completion ⇒ Object
Returns the value of attribute estimate_to_completion.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def estimate_to_completion @estimate_to_completion end |
.planned_value ⇒ Object
Returns the value of attribute planned_value.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def planned_value @planned_value end |
.project_length ⇒ Object
Returns the value of attribute project_length.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def project_length @project_length end |
.rate ⇒ Object
Returns the value of attribute rate.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def rate @rate end |
.schedule_performance_index ⇒ Object
Returns the value of attribute schedule_performance_index.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def schedule_performance_index @schedule_performance_index end |
.schedule_variance ⇒ Object
Returns the value of attribute schedule_variance.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def schedule_variance @schedule_variance end |
.variance_at_completion ⇒ Object
Returns the value of attribute variance_at_completion.
15 16 17 |
# File 'lib/earned_value_calculator.rb', line 15 def variance_at_completion @variance_at_completion end |
Class Method Details
.calculate_earned_values ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/earned_value_calculator.rb', line 68 def calculate_earned_values @earned_value = (@budget * (@rate.to_f / 100)).to_i @planned_value = (@budget * @current_length / @project_length.to_f).to_i @schedule_variance = @earned_value - @planned_value @actual_cost_variance = @earned_value - @actual_cost @cost_performance_index = @earned_value.to_f / @actual_cost @schedule_performance_index = @earned_value.to_f / @planned_value @estimate_at_completion = @actual_cost + (@budget - @planned_value) / @cost_performance_index @estimate_to_completion = @estimate_at_completion - @actual_cost @variance_at_completion = @budget - @estimate_at_completion end |
.call(start_date, end_date, current_date, budget, rate, actual_cost) ⇒ EarnedValueCalculator
Returns The object.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/earned_value_calculator.rb', line 54 def call(start_date, end_date, current_date, budget, rate, actual_cost) validator = EarnedValueCalculator::Validator .new(start_date, end_date, current_date, budget, rate, actual_cost) raise ArgumentError, validator.errors. unless validator.valid? @project_length = (start_date..end_date).select(&:workday?).size @current_length = (start_date..current_date).select(&:workday?).size @budget = budget @rate = rate @actual_cost = actual_cost calculate_earned_values self end |