Class: WhatDay::Client
- Inherits:
-
Object
show all
- Defined in:
- lib/what_day/client.rb
Constant Summary
collapse
- MONTHS =
'(jan||feb||mar||apr||may||jun||jul||aug||sep||oct||nov||dec||january||february||march||april||may||june||july||august||september||october||november||december||sept)'.freeze
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
14
15
16
17
18
19
20
21
|
# File 'lib/what_day/client.rb', line 14
def method_missing(name, *args, &block)
if name.to_s =~ Regexp.new("^(beginning||end)_of_#{MONTHS}_\\d+$", true)
date = parse_date_string(name.to_s)
day date
else
super
end
end
|
Instance Method Details
#day(date) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/what_day/client.rb', line 6
def day(date)
begin
Date::DAYNAMES[date.wday]
rescue ArgumentError
nil
end
end
|