Ruby% operator
3 answers
String#% uses the given string as the format specification and applies the argument (array / hash) and returns the resulting string.
%{...}is a link to format the name. There also %<...>, who also need a formatting style (s, d, f, ...)
"foo = %{key}" % { :key => 'bar' }
# => "foo = bar"
"foo = %<key>s" % { :key => 'bar' }
# => "foo = bar"
See the format specification for details Kernel#sprintf.
+2