Class: SimpleInvoice::BillingPeriodType

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_invoice/billing_period_type.rb,
lib/simple_invoice/billing_period_type/weekly.rb,
lib/simple_invoice/billing_period_type/monthly.rb

Direct Known Subclasses

Monthly, Weekly

Defined Under Namespace

Classes: Monthly, Weekly

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(multiple = 1) ⇒ BillingPeriodType

Returns a new instance of BillingPeriodType.

Parameters:

  • multiple (Fixnum) (defaults to: 1)


28
29
30
# File 'lib/simple_invoice/billing_period_type.rb', line 28

def initialize multiple=1
  @multiple = multiple
end

Class Method Details

.annuallyObject



20
21
22
# File 'lib/simple_invoice/billing_period_type.rb', line 20

def self.annually
  Monthly.new 12
end

.fortnightlyObject



8
9
10
# File 'lib/simple_invoice/billing_period_type.rb', line 8

def self.fortnightly
  Weekly.new 2
end

.monthlyObject



12
13
14
# File 'lib/simple_invoice/billing_period_type.rb', line 12

def self.monthly
  Monthly.new 1
end

.quarterlyObject



16
17
18
# File 'lib/simple_invoice/billing_period_type.rb', line 16

def self.quarterly
  Monthly.new 3
end

.weeklyObject



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

def self.weekly
  Weekly.new 1
end

Instance Method Details

#first_day_of_next_period(first_day) ⇒ Object

Parameters:

  • first_day (Date)


33
34
35
# File 'lib/simple_invoice/billing_period_type.rb', line 33

def first_day_of_next_period first_day
  raise "to be implemented in subclass"
end

#last_day_of_period(first_day) ⇒ Date

Parameters:

  • first_day (Date)

Returns:

  • (Date)


39
40
41
# File 'lib/simple_invoice/billing_period_type.rb', line 39

def last_day_of_period first_day
  first_day_of_next_period(first_day).prev_day
end