Class: TwitterCldr::Tokenizers::TimeTokenizer
- Inherits:
-
Object
- Object
- TwitterCldr::Tokenizers::TimeTokenizer
- Defined in:
- lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
Instance Attribute Summary collapse
-
#data_reader ⇒ Object
readonly
Returns the value of attribute data_reader.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data_reader) ⇒ TimeTokenizer
constructor
A new instance of TimeTokenizer.
- #tokenize(pattern) ⇒ Object
- #tokenizer ⇒ Object
Constructor Details
#initialize(data_reader) ⇒ TimeTokenizer
Returns a new instance of TimeTokenizer.
21 22 23 |
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 21 def initialize(data_reader) @data_reader = data_reader end |
Instance Attribute Details
#data_reader ⇒ Object (readonly)
Returns the value of attribute data_reader.
19 20 21 |
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 19 def data_reader @data_reader end |
Class Method Details
.tokenizer ⇒ Object
11 12 13 14 15 16 |
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 11 def tokenizer @tokenizer ||= Tokenizer.new([ TokenRecognizer.new(:pattern, /^(a{1}|B{1,5}|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}V{1,4}|v{1,4})/), TokenRecognizer.new(:plaintext, //) ], /(\'[\w\s-]+\'|a{1}|B{1,5}|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}|V{1,4}|v{1,4})/) end |
Instance Method Details
#tokenize(pattern) ⇒ Object
25 26 27 |
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 25 def tokenize(pattern) PatternTokenizer.new(data_reader, tokenizer).tokenize(pattern) end |
#tokenizer ⇒ Object
29 30 31 |
# File 'lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb', line 29 def tokenizer self.class.tokenizer end |