Sha256: 24631ab19748b94e373a5a452fa9b3cdb12bd0cf452ed5641507c5bd6e5cdaf8

Contents?: true

Size: 472 Bytes

Versions: 6

Compression:

Stored size: 472 Bytes

Contents

module Montrose
  class Hour
    HOURS_IN_DAY = 1.upto(24).to_a.freeze

    class << self
      def parse(arg)
        case arg
        when String
          parse(arg.split(","))
        else
          Array(arg).map { |h| assert(h.to_i) }.presence
        end
      end

      def assert(hour)
        raise ConfigurationError, "Out of range: #{HOURS_IN_DAY.inspect} does not include #{hour}" unless HOURS_IN_DAY.include?(hour)

        hour
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
montrose-0.18.0 lib/montrose/hour.rb
montrose-0.17.0 lib/montrose/hour.rb
montrose-0.16.0 lib/montrose/hour.rb
montrose-0.15.0 lib/montrose/hour.rb
montrose-0.14.0 lib/montrose/hour.rb
montrose-0.13.0 lib/montrose/hour.rb