Class: FinModeling::Rate
- Inherits:
-
Object
- Object
- FinModeling::Rate
- Defined in:
- lib/finmodeling/rate.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
- #annualize(from_days = 365, to_days = 365) ⇒ Object
-
#initialize(value) ⇒ Rate
constructor
A new instance of Rate.
- #quarterly_to_yearly ⇒ Object
- #yearly_to_quarterly ⇒ Object
Constructor Details
#initialize(value) ⇒ Rate
Returns a new instance of Rate.
5 6 7 |
# File 'lib/finmodeling/rate.rb', line 5 def initialize(value) @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/finmodeling/rate.rb', line 3 def value @value end |
Instance Method Details
#annualize(from_days = 365, to_days = 365) ⇒ Object
9 10 11 |
# File 'lib/finmodeling/rate.rb', line 9 def annualize(from_days=365, to_days=365) ((1.0 + @value)**(to_days.to_f/from_days.to_f)) - 1.0 end |
#quarterly_to_yearly ⇒ Object
17 18 19 |
# File 'lib/finmodeling/rate.rb', line 17 def quarterly_to_yearly annualize(from_days=365.0/4.0, to_days=365.0) end |
#yearly_to_quarterly ⇒ Object
13 14 15 |
# File 'lib/finmodeling/rate.rb', line 13 def yearly_to_quarterly annualize(from_days=365.0, to_days=365.0/4.0) end |