Module: BeginningOfFortnight

Defined in:
lib/beginning_of_fortnight.rb

Overview

Just a namespace and an accessor for the reference date used to define fortnight boundaries.

– (Maybe this could use cattr_accessor. Not sure if it’s worth it). ++

Constant Summary collapse

DEFAULT_REF_DATE =

Fairly arbitrary choice of reference date

Time.at(0)

Class Method Summary collapse

Class Method Details

.reference_dateObject

Provide an accessor for @@reference_date. Uses the default value if not set.



80
81
82
# File 'lib/beginning_of_fortnight.rb', line 80

def self.reference_date
  (@@reference_date ||= DEFAULT_REF_DATE).to_time
end

.reference_date=(reference_date) ⇒ Object

The ‘reference_date’ here is used to define where the fortnight boundary should be. The way it works is that the reference_date is specified such that it falls in the first half of the fortnightly period.

You can just ignore this it will use a default value but if you want to be explicit then set a date, for example:

# Define fortnight boundary
BeginningOfFortnight.reference_date = Time.parse('13-Oct-2010')

# A date should work also
BeginningOfFortnight.reference_date = Date.new(2010,10,13)


98
99
100
# File 'lib/beginning_of_fortnight.rb', line 98

def self.reference_date=(reference_date)
  @@reference_date = reference_date
end