Methods
C
D
E
H
I
M
N
R
T
Constants
TOKENIZER = /(%\{[^\}]+\}|%\{[^\}]+\})/
 
INTERPOLATION_SYNTAX_PATTERN = /(%)?(%\{([^\}]+)\})/
 
Instance Public methods
compile_if_an_interpolation(string)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 26
        def compile_if_an_interpolation(string)
          if interpolated_str?(string)
            string.instance_eval "              def i18n_interpolate(v = {})
                "#{compiled_interpolation_body(string)}"
              end
", __FILE__, __LINE__
          end
          string
        end
interpolated_str?(str)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 38
def interpolated_str?(str)
  str.kind_of?(::String) && str =~ INTERPOLATION_SYNTAX_PATTERN
end
Instance Protected methods
compile_interpolation_token(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 59
def compile_interpolation_token(key)
  "\#{#{interpolate_or_raise_missing(key)}}"
end
compiled_interpolation_body(str)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 48
def compiled_interpolation_body(str)
  tokenize(str).map do |token|
    (matchdata = token.match(INTERPOLATION_SYNTAX_PATTERN)) ? handle_interpolation_token(token, matchdata) : escape_plain_str(token)
  end.join
end
direct_key(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 72
def direct_key(key)
  "((t = v[#{key}]) && t.respond_to?(:call) ? t.call : t)"
end
escape_key_sym(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 92
def escape_key_sym(key)
  # rely on Ruby to do all the hard work :)
  key.to_sym.inspect
end
escape_plain_str(str)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 88
def escape_plain_str(str)
  str.gsub(/"|\|#/) {|x| "\\#{x}"}
end
handle_interpolation_token(interpolation, matchdata)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 54
def handle_interpolation_token(interpolation, matchdata)
  escaped, pattern, key = matchdata.values_at(1, 2, 3)
  escaped ? pattern : compile_interpolation_token(key.to_sym)
end
interpolate_key(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 68
def interpolate_key(key)
  [direct_key(key), nil_key(key), missing_key(key)].join('||')
end
interpolate_or_raise_missing(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 63
def interpolate_or_raise_missing(key)
  escaped_key = escape_key_sym(key)
  Base::RESERVED_KEYS.include?(key) ? reserved_key(escaped_key) : interpolate_key(escaped_key)
end
missing_key(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 80
def missing_key(key)
  "raise(MissingInterpolationArgument.new(#{key}, self))"
end
nil_key(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 76
def nil_key(key)
  "(v.has_key?(#{key}) && '')"
end
reserved_key(key)
# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 84
def reserved_key(key)
  "raise(ReservedInterpolationKey.new(#{key}, self))"
end
tokenize(str)

tokenize(“foo %{bar} baz %{buz}”) # => [“foo ”, “%{bar}”, “ baz ”, “%{buz}”]

# File activesupport/lib/active_support/vendor/i18n-0.4.1/i18n/backend/interpolation_compiler.rb, line 44
def tokenize(str)
  str.split(TOKENIZER)
end