Sha256: e35430b8b5f56b3613e9cedc3a5d477623f071d6d05ed5904907cdb376e6c88e
Contents?: true
Size: 952 Bytes
Versions: 9
Compression:
Stored size: 952 Bytes
Contents
#! /usr/bin/ruby =begin string.rb - Extension for String. Copyright (C) 2005,2006 Masao Mutoh You may redistribute it and/or modify it under the same license terms as Ruby. =end # Extension for String class. This feature is included in Ruby 1.9 or later. begin raise unless ("a %{x}" % {:x=>'b'}) == 'a b' rescue ArgumentError class String alias :_old_format_m :% # :nodoc: # call-seq: # %(hash) # # Default: "%s, %s" % ["Masao", "Mutoh"] # Extended: "%{firstname}, %{lastname}" % {:firstname=>"Masao",:lastname=>"Mutoh"} # # This is the recommanded way for Ruby-GetText # because the translators can understand the meanings of the msgids easily. def %(args) if args.kind_of?(Hash) ret = dup args.each {|key, value| ret.gsub!(/\%\{#{key}\}/, value.to_s)} ret else ret = gsub(/%\{/, '%%{') ret._old_format_m(args) end end end end
Version data entries
9 entries across 9 versions & 1 rubygems