Sha256: eab7f7121e464336b63279b4e53c20fec0be788e3da035972657e8469bcd90d5

Contents?: true

Size: 724 Bytes

Versions: 5

Compression:

Stored size: 724 Bytes

Contents

module Chrono
  module Fields
    class Wday < Base
      TABLE = {
        '7'   => '0',
        'sun' => '0',
        'mon' => '1',
        'tue' => '2',
        'wed' => '3',
        'thu' => '4',
        'fri' => '5',
        'sat' => '6',
      }
      REGEXP = %r<\A(?:(?<step>(?:\*|(?:(?<atom>\d+|sun|mon|tue|wed|thu|fri|sat)(?:-\g<atom>)?))(?:/\d+)?)(?:,\g<step>)*)\z>ix

      def initialize(source)
        unless REGEXP =~ source
          raise InvalidField.new('Unparsable field', source)
        end
        @source = source
      end

      private

      def interpolated
        super.downcase.gsub(/7|sun|mon|tue|wed|thu|fri|sat/, TABLE)
      end

      def range
        0..6
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chrono-0.6.0 lib/chrono/fields/wday.rb
chrono-0.5.0 lib/chrono/fields/wday.rb
chrono-0.4.0 lib/chrono/fields/wday.rb
chrono-0.3.0 lib/chrono/fields/wday.rb
chrono-0.2.0 lib/chrono/fields/wday.rb