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) ⇒ Object



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

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

.scan_for_all(token) ⇒ Object



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

def self.scan_for_all(token)
  scanner = {/\bpast\b/ => :past,
             /\bfuture\b/ => :future,
             /\bin\b/ => :future}
  scanner.keys.each do |scanner_item|
    return self.new(scanner[scanner_item]) if scanner_item =~ token.word
  end
  return nil
end

Instance Method Details

#to_sObject



22
23
24
# File 'lib/chronic/pointer.rb', line 22

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