File: time_zone.rb

package info (click to toggle)
libchronic-ruby 0.2.3-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 268 kB
  • ctags: 329
  • sloc: ruby: 2,686; makefile: 7
file content (22 lines) | stat: -rw-r--r-- 491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
module Chronic
  class TimeZone < Tag #:nodoc:    
    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

    def self.scan_for_all(token)
      scanner = {/[PMCE][DS]T/i => :tz}
      scanner.keys.each do |scanner_item|
        return self.new(scanner[scanner_item]) if scanner_item =~ token.word
      end
      return nil
    end

    def to_s
      'timezone'
    end
  end
end