Class: Chronic::Grabber

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

Overview

module Chronic

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

:nodoc:



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

def self.scan(tokens)
  tokens.each_index do |i|
    if t = self.scan_for_all(tokens[i]) then tokens[i].tag(t); next end
  end
  tokens
end

.scan_for_all(token) ⇒ Object



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

def self.scan_for_all(token)
  scanner = {/last/ => :last,
             /this/ => :this,
             /next/ => :next}
  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



21
22
23
# File 'lib/chronic/grabber.rb', line 21

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