class String
@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”`.
Public Instance Methods
%(arg, *args)
click to toggle source
# File lib/parser/compatibility/ruby1_8.rb, line 11 def %(arg, *args) if arg.is_a?(Hash) gsub(/%\{(\w+)\}/) do arg[$1.to_sym] end else original_percent(arg, *args) end end
Also aliased as: original_percent