Sha256: fc156fa17e9af2783c8593fb04bcf23fec9bc5a02e5d53187f546970cc240a59

Contents?: true

Size: 708 Bytes

Versions: 12

Compression:

Stored size: 708 Bytes

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Formatters
    class Formatter

      attr_reader :data_reader

      def initialize(data_reader)
        @data_reader = data_reader
      end

      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

      def format_plaintext(token, index, obj, options)
        token.value.gsub(/'([^']+)'/, '\1') # remove single-quote escaping for "real" characters
      end

    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
twitter_cldr-6.13.0 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.12.1 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.12.0 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.11.5 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.11.4 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.11.3 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.11.2 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.11.1 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.11.0 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.10.0 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.9.0 lib/twitter_cldr/formatters/formatter.rb
twitter_cldr-6.8.0 lib/twitter_cldr/formatters/formatter.rb