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
21
22
# File 'lib/chronic/pointer.rb', line 12

def self.scan_for_all(token)
	scanner = {/\bpast\b/i => :past,
		/\bfuture\b/i => :future,
		/\bfor\b/i => :future,
		/\bin\b/i => :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



24
25
26
# File 'lib/chronic/pointer.rb', line 24

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