Sha256: 66d29007f2fde2f7f50bb5899d7a72e9c65ba246fdffaccaae52d9f138a2cf90

Contents?: true

Size: 1.06 KB

Versions: 2

Compression:

Stored size: 1.06 KB

Contents

# encoding: UTF-8

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

module TwitterCldr
  module Localized

    class LocalizedString < LocalizedObject

      # Uses wrapped string object as a format specification and returns the result of applying it to +args+ (see
      # +TwitterCldr::Utils.interpolate+ method for interpolation syntax).
      #
      # If +args+ is a Hash than pluralization is performed before interpolation (see +PluralFormatter+ class for
      # pluralization specification).
      #
      def %(args)
        pluralized = args.is_a?(Hash) ? @formatter.format(@base_obj, args) : @base_obj
        TwitterCldr::Utils.interpolate(pluralized, args)
      end

      def formatter_const
        TwitterCldr::Formatters::PluralFormatter
      end

      def normalize(options = {})
        TwitterCldr::Normalization.normalize(@base_obj, options).localize(@locale)
      end

      def code_points
        TwitterCldr::Utils::CodePoints.from_string(@base_obj)
      end

      def to_s
        @base_obj.dup
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twitter_cldr-1.8.1 lib/twitter_cldr/localized/localized_string.rb
twitter_cldr-1.8.0 lib/twitter_cldr/localized/localized_string.rb