Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
ERB::Util.u
(::String) -> ::String
u(s)
lib/erb/util.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/erb/util.rb, line 65
def url_encode(s)
CGI.escapeURIComponent(s.to_s)
end
Alias of .url_encode
A utility method for encoding the String s as a URL.
Example
require "erb" include ERB::Util puts url_encode("Programming Ruby: The Pragmatic Programmer's Guide")
Generates
Programming%20Ruby%3A%20%20The%20Pragmatic%20Programmer%27s%20Guide