Class: RichUnits::Weekdays

Inherits:
Object
  • Object
show all
Defined in:
lib/richunits/weekdays.rb

Overview

Weekdays

The Weekdays class provides useful weekday terminology.

Thanks to Dave Hoover and Ryan Platte for the Weekdays implementation.

Defined Under Namespace

Modules: Numeric

Constant Summary collapse

WEEKDAYS =

Monday is wday 1

1..5
ONE_DAY =
60 * 60 * 24

Instance Method Summary collapse

Constructor Details

#initialize(n) ⇒ Weekdays

Returns a new instance of Weekdays.



14
15
16
# File 'lib/richunits/weekdays.rb', line 14

def initialize(n)
  @n = n
end

Instance Method Details

#ago(time = ::Time.now) ⇒ Object Also known as: until, before



18
19
20
# File 'lib/richunits/weekdays.rb', line 18

def ago(time = ::Time.now)
  step :down, time
end

#since(time = ::Time.now) ⇒ Object Also known as: from_now, after



24
25
26
# File 'lib/richunits/weekdays.rb', line 24

def since(time = ::Time.now)
  step :up, time
end