Sha256: 5b98af23d10b16fb29c6c46b2a05a52797985495ce2a36bb01ba5c28d5fd572b
Contents?: true
Size: 559 Bytes
Versions: 2
Compression:
Stored size: 559 Bytes
Contents
module CashFlowAnalysis module Calculator module Cagr # Calculates the {http://en.wikipedia.org/wiki/Compound_annual_growth_rate CAGR} based on a start value, end value, and a term. # # @param start_value [Numeric] the start value # @param end_value [Numeric] the end value # @param years [Fixnum] the number of years # @return [Numeric] the year over year growth rate def self.calculate(start_value, end_value, years) ((end_value.to_f / start_value) ** (1.0 / (years))) - 1 end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cash_flow_analysis-0.2.0 | lib/cash_flow_analysis/calculator/cagr.rb |
cash_flow_analysis-0.1.0 | lib/cash_flow_analysis/calculator/cagr.rb |