Sha256: 9ed387e98c266a2e3a799d97262bddbc49eb6f843bb995218e9a6983d019761c

Contents?: true

Size: 1.25 KB

Versions: 11

Compression:

Stored size: 1.25 KB

Contents

# encoding: UTF-8

# Copyright 2012 Twitter, Inc
# http://www.apache.org/licenses/LICENSE-2.0

module TwitterCldr
  module Tokenizers
    class TimeTokenizer < TwitterCldr::Tokenizers::DateTimeTokenizer
      TOKEN_SPLITTER_REGEX = /(\'[\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})/
      TOKEN_TYPE_REGEXES = {
        :pattern   => { :regex => /^(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})/, :priority => 1 },
        :plaintext => { :regex => //, :priority => 2 }
      }

      def initialize(options = {})
        super(options)

        @token_splitter_regexes = {
          :else => TOKEN_SPLITTER_REGEX
        }

        @token_type_regexes = {
          :else => TOKEN_TYPE_REGEXES
        }

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

      protected

      # must override this because DateTimeTokenizer will set them otherwise
      def init_placeholders
        @placeholders = {}
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
twitter_cldr-2.4.3 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-3.0.0.beta1 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.4.2 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.4.1 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.4.0 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.2.0 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.1.1 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.1.0 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.0.2 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.0.1 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb
twitter_cldr-2.0.0 lib/twitter_cldr/tokenizers/calendars/time_tokenizer.rb