Class: SimpleInvoice::BillingPeriod

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_invoice/billing_period.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(billing_period_type, first_day) ⇒ BillingPeriod

Returns a new instance of BillingPeriod.

Parameters:



8
9
10
11
12
13
14
15
# File 'lib/simple_invoice/billing_period.rb', line 8

def initialize billing_period_type, first_day
  if billing_period_type.is_a? Symbol
    @billing_period_type = BillingPeriodType.send(billing_period_type)
  else
    @billing_period_type = billing_period_type
  end
  @first_day = to_date first_day
end

Instance Attribute Details

#first_dayObject (readonly)

Returns the value of attribute first_day.



4
5
6
# File 'lib/simple_invoice/billing_period.rb', line 4

def first_day
  @first_day
end

Instance Method Details

#last_dayObject



17
18
19
# File 'lib/simple_invoice/billing_period.rb', line 17

def last_day
  @last_day ||= @billing_period_type.last_day_of_period(@first_day)
end

#next_billing_periodBillingPeriod

Returns:



22
23
24
25
# File 'lib/simple_invoice/billing_period.rb', line 22

def next_billing_period
  next_first_day = @billing_period_type.first_day_of_next_period @first_day
  self.class.new @billing_period_type, next_first_day
end