class WorkingHours::InvalidConfiguration
Attributes
data[R]
error_code[R]
Public Class Methods
new(error_code, data: nil)
click to toggle source
Calls superclass method
# File lib/working_hours/config.rb, line 7 def initialize(error_code, data: nil) @data = data @error_code = error_code super compose_message(error_code) end
Public Instance Methods
compose_message(error_code)
click to toggle source
# File lib/working_hours/config.rb, line 13 def compose_message(error_code) case error_code when :empty then "No working hours given" when :empty_day then "No working hours given for day `#{@data[:day]}`" when :holidays_not_array then "Invalid type for holidays: #{@data[:holidays_class]} - must act like an array" when :holiday_not_date then "Invalid holiday: #{@data[:day]} - must be Date" when :invalid_day_keys then "Invalid day identifier(s): #{@data[:invalid_keys]} - must be 3 letter symbols" when :invalid_format then "Invalid time: #{@data[:time]} - must be 'HH:MM(:SS)'" when :invalid_holiday_keys then "Invalid day identifier(s): #{@data[:invalid_keys]} - must be a Date object" when :invalid_timezone then "Invalid time zone: #{@data[:zone]} - must be String or ActiveSupport::TimeZone" when :invalid_type then "Invalid type for `#{@data[:day]}`: #{@data[:hours_class]} - must be Hash" when :outside_of_day then "Invalid time: #{@data[:time]} - outside of day" when :overlap then "Invalid range: #{@data[:start]} => #{@data[:finish]} - overlaps previous range" when :unknown_timezone then "Unknown time zone: #{@data[:zone]}" when :wrong_order then "Invalid range: #{@data[:start]} => #{@data[:finish]} - ends before it starts" else "Invalid Configuration" end end