Class: ROI::FinancialResult
- Inherits:
-
Object
- Object
- ROI::FinancialResult
- Defined in:
- lib/roi/financial_result.rb
Instance Attribute Summary collapse
-
#end_date ⇒ Object
readonly
Returns the value of attribute end_date.
-
#rentabilities ⇒ Object
readonly
Returns the value of attribute rentabilities.
-
#start_date ⇒ Object
readonly
Returns the value of attribute start_date.
Instance Method Summary collapse
- #current_month ⇒ Object
- #current_year ⇒ Object
-
#initialize(rentabilities, start_date, end_date) ⇒ FinancialResult
constructor
A new instance of FinancialResult.
- #months(amount) ⇒ Object
- #portfolio ⇒ Object
- #years_ago(amount) ⇒ Object
Constructor Details
#initialize(rentabilities, start_date, end_date) ⇒ FinancialResult
Returns a new instance of FinancialResult.
9 10 11 12 13 |
# File 'lib/roi/financial_result.rb', line 9 def initialize(rentabilities, start_date, end_date) @rentabilities = rentabilities @start_date = start_date @end_date = end_date end |
Instance Attribute Details
#end_date ⇒ Object (readonly)
Returns the value of attribute end_date.
7 8 9 |
# File 'lib/roi/financial_result.rb', line 7 def end_date @end_date end |
#rentabilities ⇒ Object (readonly)
Returns the value of attribute rentabilities.
7 8 9 |
# File 'lib/roi/financial_result.rb', line 7 def rentabilities @rentabilities end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
7 8 9 |
# File 'lib/roi/financial_result.rb', line 7 def start_date @start_date end |
Instance Method Details
#current_month ⇒ Object
15 16 17 18 |
# File 'lib/roi/financial_result.rb', line 15 def current_month scope_start = WorkDay.next_after(end_date.beginning_of_month, 0) format_financial(scope_start, end_date) end |
#current_year ⇒ Object
25 26 27 28 |
# File 'lib/roi/financial_result.rb', line 25 def current_year scope_start = WorkDay.next_after(end_date.beginning_of_year, 0) format_financial(scope_start, end_date) end |
#months(amount) ⇒ Object
20 21 22 23 |
# File 'lib/roi/financial_result.rb', line 20 def months(amount) scope_start = (end_date - amount.months + 1.month).beginning_of_month check_gaps_and_format(scope_start, end_date) end |
#portfolio ⇒ Object
36 37 38 |
# File 'lib/roi/financial_result.rb', line 36 def portfolio format_financial(start_date, end_date) end |
#years_ago(amount) ⇒ Object
30 31 32 33 34 |
# File 'lib/roi/financial_result.rb', line 30 def years_ago(amount) scope_end = (end_date - amount.year).end_of_year scope_start = scope_end.beginning_of_year format_financial(scope_start, scope_end) end |