Class: Date

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

Constant Summary collapse

WDAYS =
[0, 1, 2, 3, 4, 5, 6]
WEEKEND_WDAYS =
[0, 6]
WEEKEND_DAYNAMES =
DAYNAMES.values_at(*WEEKEND_WDAYS)
WEEKEND_ABBR_DAYNAMES =
ABBR_DAYNAMES.values_at(*WEEKEND_WDAYS)
WORKWEEK_WDAYS =
[1, 2, 3, 4, 5]
WORKWEEK_DAYNAMES =
DAYNAMES.values_at(*WORKWEEK_WDAYS)
WORKWEEK_ABBR_DAYNAMES =
ABBR_DAYNAMES.values_at(*WORKWEEK_WDAYS)

Instance Method Summary collapse

Instance Method Details

#weekend?Boolean

Returns true if the date is a weekend day: Sat, Sun.

Examples:

d = Date.parse('2008-01-05')
d.wday => 6
d.weekend? => true


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

def weekend?
  WEEKEND_WDAYS.include? wday
end

#workweek?Boolean

Returns true if the date is a workweek day: Mon, Tue, Wed, Thu, Fri.

Examples:

d = Date.parse('2008-01-01')
d.wday => 2
d.weekday? => true


27
28
29
# File 'lib/sixarm_ruby_date_days.rb', line 27

def workweek?
  WORKWEEK_WDAYS.include? wday
end