Sha256: 678af78e797d61525c01ea9db74456acf49d2568ec3848bcbf6d8eef3de7854a

Contents?: true

Size: 774 Bytes

Versions: 7

Compression:

Stored size: 774 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, options = {})
      @type = type
      @options = options
    end

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

    class << self
      private

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

    end

  end
end

Version data entries

7 entries across 7 versions & 4 rubygems

Version Path
gitlab-chronic-0.10.6 lib/chronic/tag.rb
gitlab-chronic-0.10.5 lib/chronic/tag.rb
asana2flowdock-1.0.0 vendor/bundle/ruby/1.9.1/gems/chronic-0.10.2/lib/chronic/tag.rb
chronic-mmlac-0.10.2.1 lib/chronic/tag.rb
chronic-0.10.2 lib/chronic/tag.rb
chronic-0.10.1 lib/chronic/tag.rb
chronic-0.10.0 lib/chronic/tag.rb