Class: TwitterCldr::Tokenizers::DateTokenizer

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_reader) ⇒ DateTokenizer

Returns a new instance of DateTokenizer.



21
22
23
# File 'lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb', line 21

def initialize(data_reader)
  @data_reader = data_reader
end

Instance Attribute Details

#data_readerObject (readonly)

Returns the value of attribute data_reader.



19
20
21
# File 'lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb', line 19

def data_reader
  @data_reader
end

Class Method Details

.tokenizerObject



11
12
13
14
15
16
# File 'lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb', line 11

def tokenizer
  @tokenizer ||= Tokenizer.new([
    TokenRecognizer.new(:pattern, /^(?: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}|w{1,2}|W{1})/),
    TokenRecognizer.new(:plaintext, //)
  ], /(\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}|w{1,2}|W{1}|\#\{[^\}]+\})/)
end

Instance Method Details

#tokenize(pattern) ⇒ Object



25
26
27
# File 'lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb', line 25

def tokenize(pattern)
  PatternTokenizer.new(data_reader, tokenizer).tokenize(pattern)
end

#tokenizerObject



29
30
31
# File 'lib/twitter_cldr/tokenizers/calendars/date_tokenizer.rb', line 29

def tokenizer
  self.class.tokenizer
end