Sha256: e13f473c905ee9f08179ac1d52455ff15a5e57f109a7e6b8a601abff2c3e249a
Contents?: true
Size: 382 Bytes
Versions: 76
Compression:
Stored size: 382 Bytes
Contents
## # @api public # # This monkeypatch extends Ruby 1.8 {String#%} with an ability # to replace named capture groups, i.e. # `"foo: %{bar}" % { :bar => 10 } # => "foo: 10"`. # class String alias original_percent % def %(arg, *args) if arg.is_a?(Hash) gsub(/%\{(\w+)\}/) do arg[$1.to_sym] end else original_percent(arg, *args) end end end
Version data entries
76 entries across 76 versions & 5 rubygems