Class: TwitterCldr::Tokenizers::TimeTokenizer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data_reader) ⇒ TimeTokenizer

Returns a new instance of TimeTokenizer.



12
13
14
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 12

def initialize(data_reader)
  @data_reader = data_reader
end

Instance Attribute Details

#data_readerObject (readonly)

Returns the value of attribute data_reader.



10
11
12
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 10

def data_reader
  @data_reader
end

Instance Method Details

#tokenize(pattern) ⇒ Object



16
17
18
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 16

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

#tokenizerObject



20
21
22
23
24
25
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 20

def tokenizer
  @tokenizer ||= Tokenizer.new([
    TokenRecognizer.new(:pattern, /^(a{1}|h{1,2}|H{1,2}|K{1,2}|k{1,2}|m{1,2}|s{1,2}|S+|z{1,4}|Z{1,4})/),
    TokenRecognizer.new(:plaintext, //)
  ], /(\'[\w\s-]+\'|a{1}|h{1,2}|H{1,2}|K{1,2}|k{1,2}|m{1,2}|s{1,2}|S+|z{1,4}|Z{1,4})/)
end