Sha256: 9c7d38e92b1d4c974e22820036f059ca499cce97fc6a37fc743fffbbb019374c
Contents?: true
Size: 1.09 KB
Versions: 14
Compression:
Stored size: 1.09 KB
Contents
# encoding: UTF-8 # Copyright 2012 Twitter, Inc # http://www.apache.org/licenses/LICENSE-2.0 module TwitterCldr module Formatters class Base attr_reader :tokenizer def format(obj, options = {}) process_tokens(self.get_tokens(obj, options), obj) end protected def process_tokens(tokens, obj) result = '' tokens.each_with_index do |token, index| case token.type when :composite result << eval(process_tokens(token.tokens, obj)).to_s when :pattern result << self.result_for_token(token, index, obj) else if token.value.size > 0 && token.value[0].chr == "'" && token.value[-1].chr == "'" result << token.value[1..-2] else result << token.value end end end result end def get_tokens(obj, options = {}) @tokenizer.tokens(options) end def extract_locale(options) options[:locale] || TwitterCldr::DEFAULT_LOCALE end end end end
Version data entries
14 entries across 14 versions & 1 rubygems