Sha256: 0b6833992fd935101809643838abe6f72be47004165bc90e71469e7d6d51ad46

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

module Chronic
  class Pointer < Tag

    # Scan an Array of Token objects and apply any necessary Pointer
    # tags to each token.
    #
    # tokens - An Array of tokens to scan.
    # options - The Hash of options specified in Chronic::parse.
    #
    # Returns an Array of tokens.
    def self.scan(tokens, options)
      tokens.each do |token|
        token.tag scan_for(token, self, patterns, options)
      end
    end

    def self.patterns
      @@patterns ||= {
        /^ago|before|prior|till|to$/i     => :past,
        /^future|hence|from|after|past$/i => :future
      }
    end

    def to_s
      'pointer-' << @type.to_s
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chronic-davispuh-0.10.2.v0.1da32066b3f46f2506b3471e39557497e34afa27 lib/chronic/tags/pointer.rb