Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/parser/compatibility/ruby1_8.rb
Overview
This monkeypatch extends Ruby 1.8 #% with an ability
to replace named capture groups, i.e.
"foo: %{bar}" % { :bar => 10 } # => "foo: 10"
.
Instance Method Summary (collapse)
Instance Method Details
- (Object) %(arg, *args)
11 12 13 14 15 16 17 18 19 |
# 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 |
- (Object) original_percent
9 |
# File 'lib/parser/compatibility/ruby1_8.rb', line 9 alias original_percent % |