Class: SimpleInvoice::BillingPeriod
- Inherits:
-
Object
- Object
- SimpleInvoice::BillingPeriod
- Defined in:
- lib/simple_invoice/billing_period.rb
Instance Attribute Summary collapse
-
#first_day ⇒ Object
readonly
Returns the value of attribute first_day.
Instance Method Summary collapse
-
#initialize(billing_period_type, first_day) ⇒ BillingPeriod
constructor
A new instance of BillingPeriod.
- #last_day ⇒ Object
- #next_billing_period ⇒ BillingPeriod
Constructor Details
#initialize(billing_period_type, first_day) ⇒ BillingPeriod
Returns a new instance of BillingPeriod.
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_day ⇒ Object (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_day ⇒ Object
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_period ⇒ BillingPeriod
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 |