Exception: WorkingHours::InvalidConfiguration
- Inherits:
-
StandardError
- Object
- StandardError
- WorkingHours::InvalidConfiguration
- Defined in:
- lib/working_hours/config.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error_code ⇒ Object
readonly
Returns the value of attribute error_code.
Instance Method Summary collapse
- #compose_message(error_code) ⇒ Object
-
#initialize(error_code, data: nil) ⇒ InvalidConfiguration
constructor
A new instance of InvalidConfiguration.
Constructor Details
#initialize(error_code, data: nil) ⇒ InvalidConfiguration
Returns a new instance of InvalidConfiguration.
7 8 9 10 11 |
# File 'lib/working_hours/config.rb', line 7 def initialize(error_code, data: nil) @data = data @error_code = error_code super (error_code) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/working_hours/config.rb', line 5 def data @data end |
#error_code ⇒ Object (readonly)
Returns the value of attribute error_code.
5 6 7 |
# File 'lib/working_hours/config.rb', line 5 def error_code @error_code end |
Instance Method Details
#compose_message(error_code) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/working_hours/config.rb', line 13 def (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 |