Sha256: 3c8075962e040bb31f21a81f77319697c31310ed179f4a2e6fbb83acd055acb7

Contents?: true

Size: 469 Bytes

Versions: 4

Compression:

Stored size: 469 Bytes

Contents

#! /usr/bin/ruby
=begin
  string.rb - Extension for String.

  Copyright (C) 2005  Masao Mutoh
 
  You may redistribute it and/or modify it under the same
  license terms as Ruby.
=end

class String
  alias :_old_format_m :%
    
  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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gettext-1.1.1-mswin32 lib/gettext/string.rb
gettext-1.1.0-mswin32 lib/gettext/string.rb
gettext-1.1.1 lib/gettext/string.rb
gettext-1.1.0 lib/gettext/string.rb