Module: Holidays::CoreExtensions::Date
- Defined in:
- lib/holidays/core_extensions/date.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#holiday?(*options) ⇒ Boolean
Check if the current date is a holiday.
-
#holidays(*options) ⇒ Object
Get holidays on the current date.
Class Method Details
.included(base) ⇒ Object
4 5 6 |
# File 'lib/holidays/core_extensions/date.rb', line 4 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#holiday?(*options) ⇒ Boolean
Check if the current date is a holiday.
Returns true or false.
Date.civil('2008-01-01').holiday?(:ca)
=> true
27 28 29 30 |
# File 'lib/holidays/core_extensions/date.rb', line 27 def holiday?(*) holidays = self.holidays() holidays && !holidays.empty? end |
#holidays(*options) ⇒ Object
Get holidays on the current date.
Returns an array of hashes or nil. See Holidays#between for options and the output format.
Date.civil('2008-01-01').holidays(:ca_)
=> [{:name => 'New Year\'s Day',...}]
Also available via Holidays#on.
17 18 19 |
# File 'lib/holidays/core_extensions/date.rb', line 17 def holidays(*) Holidays.on(self, ) end |