Sha256: 74dddc778903831428ea6c5d97b8de3fce25ac832c341de2953fe88182015d2e
Contents?: true
Size: 1.12 KB
Versions: 5
Compression:
Stored size: 1.12 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, options) end protected def process_tokens(tokens, obj, options = {}) 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, options) 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
5 entries across 5 versions & 1 rubygems