Class: Chronic::Pointer

Inherits:
Tag
  • Object
show all
Defined in:
lib/chronic/pointer.rb

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from Tag

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tag

#initialize, #start=

Constructor Details

This class inherits a constructor from Chronic::Tag

Class Method Details

.scan(tokens, options) ⇒ Object



4
5
6
7
8
9
# File 'lib/chronic/pointer.rb', line 4

def self.scan(tokens, options)
  # for each token
  tokens.each_index do |i|
    if t = scan_for_all(tokens[i]) then tokens[i].tag(t) end
  end
end

.scan_for_all(token) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/chronic/pointer.rb', line 11

def self.scan_for_all(token)
  scan_for token, self,
  {
    /\bpast\b/ => :past,
    /\bfuture\b/ => :future,
    /\bin\b/ => :future
  }
end

Instance Method Details

#to_sObject



20
21
22
# File 'lib/chronic/pointer.rb', line 20

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