Class: TwitterCldr::Tokenizers::DateTokenizer

Inherits:
DateTimeTokenizer show all
Defined in:
lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb

Constant Summary

Constants inherited from DateTimeTokenizer

TwitterCldr::Tokenizers::DateTimeTokenizer::VALID_TYPES

Instance Attribute Summary

Attributes inherited from DateTimeTokenizer

#calendar_type, #placeholders

Attributes inherited from Base

#locale, #paths, #placeholders, #resource, #token_splitter_regex, #token_type_regexes, #type

Instance Method Summary collapse

Methods inherited from DateTimeTokenizer

#calendar, #tokens

Constructor Details

#initialize(options = {}) ⇒ DateTokenizer

Returns a new instance of DateTokenizer.


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb', line 9

def initialize(options = {})
  super(options)
  @token_splitter_regex = /(\s*\'[\w\s-]+\'\s*|G{1,5}|y+|Y+|Q{1,4}|q{1,5}|M{1,5}|L{1,5}|d{1,2}|F{1}|E{1,5}|e{1,5}|c{1,5}|\#\{[^\}]+\})/

  @token_type_regexes = [
      { :type => :composite, :regex => /^\#\{[^\}]+\}/, :content => /^\#\{([^\}]+)\}/ },
      { :type => :pattern,   :regex => /^(?:G{1,5}|y+|Y+|Q{1,4}|q{1,5}|M{1,5}|L{1,5}|d{1,2}|F{1}|E{1,5}|e{1,5}|c{1,5})/ },
      { :type => :plaintext, :regex => // }
  ]

  @paths = {
      :default => [:formats, :date, :default],
      :full    => [:formats, :date, :full],
      :long    => [:formats, :date, :long],
      :medium  => [:formats, :date, :medium],
      :short   => [:formats, :date, :short]
  }
end