Class: Chronic::TimeZone

Inherits:
Tag
  • Object
show all
Defined in:
lib/chronic/time_zone.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



3
4
5
6
7
8
# File 'lib/chronic/time_zone.rb', line 3

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



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

def self.scan_for_all(token)
  scanner = {/[PMCE][DS]T/i => :tz,
             /(tzminus)?\d{4}/ => :tz}
  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



19
20
21
# File 'lib/chronic/time_zone.rb', line 19

def to_s
  'timezone'
end