Sha256: edb0eb8a3bd64bbf72fbea5215a08da75bd63c7779ce8ebd2f1d3ba3a4d01741

Contents?: true

Size: 552 Bytes

Versions: 3

Compression:

Stored size: 552 Bytes

Contents

# frozen_string_literal: true

require_relative 'error'

module UKAcademicCalendar
  # Error class raised when a concrete term class is deemed to have an invalid date-bound
  class InvalidTermBound < Error
    def initialize(date, comparand)
      @date = date
      @comparand = comparand
      super(message)
    end

    # @return [String]
    def message
      "#{@date} is invalid. Must be #{comparison_qualifier} #{@comparand}"
    end

    private

    def comparison_qualifier
      @comparand.instance_of?(Range) && 'within'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
uk_academic_calendar-1.1.0 lib/uk_academic_calendar/errors/invalid_term_bound.rb
uk_academic_calendar-1.0.1 lib/uk_academic_calendar/errors/invalid_term_bound.rb
uk_academic_calendar-1.0.0 lib/uk_academic_calendar/errors/invalid_term_bound.rb