Module: Thoran::String::UrlEncode

Defined in:
lib/Thoran/String/UrlEncode/url_encode.rb

Instance Method Summary collapse

Instance Method Details

#url_encodeObject



16
17
18
19
20
# File 'lib/Thoran/String/UrlEncode/url_encode.rb', line 16

def url_encode
  self.gsub(/([^ a-zA-Z0-9_.-]+)/n) do
    '%' + $1.unpack('H2' * $1.size).join('%').upcase
  end.tr(' ', '+')
end