Class: ROI::GrossProfit
- Inherits:
-
Object
- Object
- ROI::GrossProfit
- Defined in:
- lib/roi/gross_profit.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) ⇒ GrossProfit
constructor
A new instance of GrossProfit.
- #months(amount) ⇒ Object
- #portfolio ⇒ Object
- #years_ago(amount) ⇒ Object
Constructor Details
#initialize(rentabilities, start_date, end_date) ⇒ GrossProfit
Returns a new instance of GrossProfit.
11 12 13 14 15 |
# File 'lib/roi/gross_profit.rb', line 11 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.
9 10 11 |
# File 'lib/roi/gross_profit.rb', line 9 def end_date @end_date end |
#rentabilities ⇒ Object (readonly)
Returns the value of attribute rentabilities.
9 10 11 |
# File 'lib/roi/gross_profit.rb', line 9 def rentabilities @rentabilities end |
#start_date ⇒ Object (readonly)
Returns the value of attribute start_date.
9 10 11 |
# File 'lib/roi/gross_profit.rb', line 9 def start_date @start_date end |
Instance Method Details
#current_month ⇒ Object
17 18 19 20 |
# File 'lib/roi/gross_profit.rb', line 17 def current_month scope_start = WorkDay.next_after(end_date.beginning_of_month, 0) format_gross_profit(scope_start, end_date) end |
#current_year ⇒ Object
27 28 29 30 |
# File 'lib/roi/gross_profit.rb', line 27 def current_year scope_start = WorkDay.next_after(end_date.beginning_of_year, 0) format_gross_profit(scope_start, end_date) end |
#months(amount) ⇒ Object
22 23 24 25 |
# File 'lib/roi/gross_profit.rb', line 22 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
38 39 40 |
# File 'lib/roi/gross_profit.rb', line 38 def portfolio format_gross_profit(start_date, end_date) end |
#years_ago(amount) ⇒ Object
32 33 34 35 36 |
# File 'lib/roi/gross_profit.rb', line 32 def years_ago(amount) scope_end = (end_date - amount.year).end_of_year scope_start = scope_end.beginning_of_year format_gross_profit(scope_start, scope_end) end |