Class: ROI::FinancialResult

Inherits:
Object
  • Object
show all
Defined in:
lib/roi/financial_result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_dateObject (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

#rentabilitiesObject (readonly)

Returns the value of attribute rentabilities.



7
8
9
# File 'lib/roi/financial_result.rb', line 7

def rentabilities
  @rentabilities
end

#start_dateObject (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_monthObject



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_yearObject



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

#portfolioObject



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