Sha256: ea1bb94368affa7b7ac0505d45480a31c742ee125d0c18b73cbc46db93f9b691

Contents?: true

Size: 703 Bytes

Versions: 21

Compression:

Stored size: 703 Bytes

Contents

module Chronic
  # Tokens are tagged with subclassed instances of this class when
  # they match specific criteria.
  class Tag

    attr_accessor :type

    # type - The Symbol type of this tag.
    def initialize(type)
      @type = type
    end

    # time - Set the start Time for this Tag.
    def start=(time)
      @now = time
    end

    class << self
      private

      def scan_for(token, klass, items={})
        case items
        when Regexp
          return klass.new(token.word) if items =~ token.word
        when Hash
          items.each do |item, symbol|
            return klass.new(symbol) if item =~ token.word
          end
        end
        nil
      end

    end

  end
end

Version data entries

21 entries across 21 versions & 4 rubygems

Version Path
chronic-0.9.1 lib/chronic/tag.rb
chronic-0.9.0 lib/chronic/tag.rb
Hokkaido-0.1.5 chronic/lib/chronic/tag.rb
Hokkaido-0.1.4 chronic/lib/chronic/tag.rb
Hokkaido-0.1.3 chronic/lib/chronic/tag.rb
Hokkaido-0.1.2 chronic/lib/chronic/tag.rb
Hokkaido-0.1.1 chronic/lib/chronic/tag.rb
Hokkaido-0.1.0 chronic/lib/chronic/tag.rb
Hokkaido-0.0.9 chronic/lib/chronic/tag.rb
Hokkaido-0.0.6 chronic/lib/chronic/tag.rb
Hokkaido-0.0.5 chronic/lib/chronic/tag.rb
Hokkaido-0.0.4 chronic/lib/chronic/tag.rb
chronic-0.8.0 lib/chronic/tag.rb
chronic-0.7.0 lib/chronic/tag.rb
chronic_2001-0.1.5 lib/chronic/tag.rb
chronic_2001-0.1.4 lib/chronic/tag.rb
chronic_2001-0.1.3 lib/chronic/tag.rb
chronic_2001-0.1.2 lib/chronic/tag.rb
chronic_2001-0.1.1 lib/chronic/tag.rb
chronic_2001-0.1.0 lib/chronic/tag.rb