class RussianWorkdays::Day
Public Class Methods
new(date)
click to toggle source
# 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
Public Instance Methods
holiday?()
click to toggle source
# File lib/russian_workdays/day.rb, line 15 def holiday? !preholiday? && (weekend? || DATES[@date.year][:holidays].include?(@date)) end
preholiday?()
click to toggle source
# File lib/russian_workdays/day.rb, line 19 def preholiday? DATES[@date.year][:preholidays].include?(@date) end
type()
click to toggle source
# File lib/russian_workdays/day.rb, line 27 def type return :holiday if holiday? return :preholiday if preholiday? return :work if work? end
work?()
click to toggle source
# File lib/russian_workdays/day.rb, line 23 def work? !holiday? end
Private Instance Methods
weekend?()
click to toggle source
# File lib/russian_workdays/day.rb, line 35 def weekend? @date.sunday? || @date.saturday? end