Module: ROI::RentabilityPeriods

Included in:
Rentability
Defined in:
lib/roi/rentability_periods.rb

Instance Method Summary collapse

Instance Method Details

#current_monthObject



12
13
14
15
# File 'lib/roi/rentability_periods.rb', line 12

def current_month
  scoped_start = WorkDay.last_until((end_date - 1.month).end_of_month)
  check_gaps_and_format(adjust_start_date(scoped_start), end_date)
end

#current_yearObject



24
25
26
27
# File 'lib/roi/rentability_periods.rb', line 24

def current_year
  scoped_start = WorkDay.last_until((end_date - 1.year).end_of_year)
  format(adjust_start_date(scoped_start), end_date)
end

#days(days_amount = 1) ⇒ Object



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

def days(days_amount = 1)
  scoped_start = WorkDay.last_until(end_date - days_amount)
  format(scoped_start, end_date)
end

#months(amount, date = end_date) ⇒ Object



17
18
19
20
21
22
# File 'lib/roi/rentability_periods.rb', line 17

def months(amount, date = end_date)
  scoped_start =
    WorkDay.last_until((date - (amount + 1).month).end_of_month)
  scoped_end = adjust_end_date((date - 1.month).end_of_month)
  check_gaps_and_format(scoped_start, scoped_end)
end

#portfolioObject



35
36
37
# File 'lib/roi/rentability_periods.rb', line 35

def portfolio
  format(start_date, end_date)
end

#years_ago(amount) ⇒ Object



29
30
31
32
33
# File 'lib/roi/rentability_periods.rb', line 29

def years_ago(amount)
  scoped_end = WorkDay.last_until((end_date - amount.year).end_of_year)
  scoped_start = WorkDay.last_until((scoped_end - 1.year).end_of_year)
  format(adjust_start_date(scoped_start), scoped_end)
end