Sha256: e6835f7a036ee17275a8ebaf918a806e2ec97fec883461ca1caf907fd5473918

Contents?: true

Size: 527 Bytes

Versions: 6

Compression:

Stored size: 527 Bytes

Contents

module Montrose
  class YearDay
    class << self
      YDAYS = 1.upto(366).to_a

      def parse(ydays)
        return nil unless ydays.present?

        case ydays
        when String
          parse(ydays.split(","))
        else
          Array(ydays).map { |d| assert(d.to_i) }
        end
      end

      def assert(number)
        test = number.abs
        raise ConfigurationError, "Out of range: #{YDAYS.inspect} does not include #{test}" unless YDAYS.include?(number.abs)

        number
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

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