class TwitterCldr::Formatters::Formatter

Attributes

data_reader[R]

Public Class Methods

new(data_reader) click to toggle source
# File lib/twitter_cldr/formatters/formatter.rb, line 12
def initialize(data_reader)
  @data_reader = data_reader
end

Public Instance Methods

format(tokens, obj, options = {}) click to toggle source
# File lib/twitter_cldr/formatters/formatter.rb, line 16
def format(tokens, obj, options = {})
  tokens.each_with_index.inject("") do |ret, (token, index)|
    method_sym = :"format_#{token.type}"
    ret << send(method_sym, token, index, obj, options)
  end
end

Protected Instance Methods

format_composite(token, index, obj, options) click to toggle source
# File lib/twitter_cldr/formatters/formatter.rb, line 29
def format_composite(token, index, obj, options)
  eval(format(token.tokens, obj)).to_s
end
format_plaintext(token, index, obj, options) click to toggle source
# File lib/twitter_cldr/formatters/formatter.rb, line 25
def format_plaintext(token, index, obj, options)
  token.value.gsub(/'([^']+)'/, '\1') # remove single-quote escaping for "real" characters
end