Class: TwitterCldr::Tokenizers::DateTimeTokenizer
- Defined in:
- lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb
Direct Known Subclasses
Constant Summary collapse
- VALID_TYPES =
[:default, :full, :long, :medium, :short]
Instance Attribute Summary collapse
-
#calendar_type ⇒ Object
readonly
Returns the value of attribute calendar_type.
-
#placeholders ⇒ Object
readonly
Returns the value of attribute placeholders.
Attributes inherited from Base
#locale, #paths, #resource, #token_splitter_regex, #token_type_regexes, #type
Instance Method Summary collapse
- #calendar ⇒ Object
-
#initialize(options = {}) ⇒ DateTimeTokenizer
constructor
A new instance of DateTimeTokenizer.
- #tokens(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ DateTimeTokenizer
Returns a new instance of DateTimeTokenizer.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb', line 13 def initialize( = {}) @calendar_type = [:calendar_type] || TwitterCldr::DEFAULT_CALENDAR_TYPE @token_splitter_regex = // @token_type_regexes = [{ :type => :plaintext, :regex => // }] @base_path = [:calendars] @paths = { :default => [:formats, :datetime, :default], :full => [:formats, :datetime, :full], :long => [:formats, :datetime, :long], :medium => [:formats, :datetime, :medium], :short => [:formats, :datetime, :short] } super() end |
Instance Attribute Details
#calendar_type ⇒ Object (readonly)
Returns the value of attribute calendar_type.
9 10 11 |
# File 'lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb', line 9 def calendar_type @calendar_type end |
#placeholders ⇒ Object (readonly)
Returns the value of attribute placeholders.
9 10 11 |
# File 'lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb', line 9 def placeholders @placeholders end |
Instance Method Details
#calendar ⇒ Object
37 38 39 |
# File 'lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb', line 37 def calendar @resource[:calendars][@calendar_type] end |
#tokens(options = {}) ⇒ Object
32 33 34 35 |
# File 'lib/twitter_cldr/tokenizers/calendars/datetime_tokenizer.rb', line 32 def tokens( = {}) type = [:type] || :default tokens_for(full_path_for(paths[type]), type) end |