Class: Symian::CostAnalyzer
- Inherits:
-
Object
- Object
- Symian::CostAnalyzer
- Defined in:
- lib/symian/cost_analyzer.rb
Instance Method Summary collapse
- #evaluate(kpis) ⇒ Object
-
#initialize(configuration) ⇒ CostAnalyzer
constructor
A new instance of CostAnalyzer.
Constructor Details
#initialize(configuration) ⇒ CostAnalyzer
Returns a new instance of CostAnalyzer.
5 6 7 8 9 10 |
# File 'lib/symian/cost_analyzer.rb', line 5 def initialize(configuration) @configuration = configuration unless @configuration.cost_analysis[:operations] raise ArgumentError, 'No operations cost configuration provided!' end end |
Instance Method Details
#evaluate(kpis) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/symian/cost_analyzer.rb', line 12 def evaluate(kpis) # evaluate operation costs operations_cost = @configuration.support_groups.inject(0.0) do |sum,(sg_name,sg_conf)| sg_costs = @configuration.cost_analysis[:operations].find{|sg| sg[:sg_name] == sg_name } unless sg_costs raise "Cannot find salaries for support group #{sg_name}!" end # ugly hack sum += sg_conf[:operators][:number] * sg_costs[:operator_salary] end # need to consider daily costs (salaries are annual) operations_cost /= 365.0 # evaluate contracting costs (SLO violations) contracting_func = @configuration.cost_analysis[:contracting] contracting_cost = (contracting_func.nil? ? 0.0 : (contracting_func.call(kpis) or 0.0)) # evaluate drift costs drift_func = @configuration.cost_analysis[:drift] drift_cost = (drift_func.nil? ? 0.0 : (drift_func.call(kpis) or 0.0)) # return result { :operations => operations_cost, :contracting => contracting_cost, :drift => drift_cost } end |