Class: RussianWorkdays::Day
- Inherits:
-
Object
- Object
- RussianWorkdays::Day
- Defined in:
- lib/russian_workdays/day.rb
Instance Method Summary collapse
- #holiday? ⇒ Boolean
-
#initialize(date) ⇒ Day
constructor
A new instance of Day.
- #preholiday? ⇒ Boolean
- #type ⇒ Object
- #work? ⇒ Boolean
Constructor Details
#initialize(date) ⇒ Day
Returns a new instance of Day.
9 10 11 12 13 |
# File 'lib/russian_workdays/day.rb', line 9 def initialize(date) @date = date raise ArgumentError, "Must be a Date object" unless @date.is_a?(::Date) raise ArgumentError, "Data missing for that year" unless DATES.key?(@date.year) end |
Instance Method Details
#holiday? ⇒ Boolean
15 16 17 |
# File 'lib/russian_workdays/day.rb', line 15 def holiday? !preholiday? && (weekend? || DATES[@date.year][:holidays].include?(@date)) end |
#preholiday? ⇒ Boolean
19 20 21 |
# File 'lib/russian_workdays/day.rb', line 19 def preholiday? DATES[@date.year][:preholidays].include?(@date) end |
#type ⇒ Object
27 28 29 30 31 |
# File 'lib/russian_workdays/day.rb', line 27 def type return :holiday if holiday? return :preholiday if preholiday? return :work if work? end |
#work? ⇒ Boolean
23 24 25 |
# File 'lib/russian_workdays/day.rb', line 23 def work? !holiday? end |