lib/ronin/formatting/extensions/http/string.rb in ronin-0.2.4 vs lib/ronin/formatting/extensions/http/string.rb in ronin-0.3.0
- old
+ new
@@ -1,9 +1,7 @@
#
-#--
-# Ronin - A Ruby platform designed for information security and data
-# exploration tasks.
+# Ronin - A Ruby platform for exploit development and security research.
#
# Copyright (c) 2006-2009 Hal Brodigan (postmodern.mod3 at gmail.com)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,62 +14,71 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#++
#
require 'ronin/formatting/extensions/text'
require 'uri'
require 'cgi'
class String
#
- # Returns the URI encoded form of the string.
+ # @return [String]
+ # The URI encoded form of the String.
#
+ # @example
# "art is graffiti".uri_encode
# # => "art%20is%20graffiti"
#
def uri_encode
URI.encode(self)
end
#
- # Returns the decoded URI form of the string.
+ # @return [String]
+ # The decoded URI form of the String.
#
+ # @example
# "genre%3f".uri_decode
# # => "genre?"
#
def uri_decode
URI.decode(self)
end
#
- # Returns the URI escaped form of the string.
+ # @return [String]
+ # The URI escaped form of the String.
#
+ # @example
# "x > y".uri_escape
# # => "x+%3E+y"
#
def uri_escape
CGI.escape(self)
end
#
- # Returns the unescaped URI form of the string.
+ # @return [String]
+ # The unescaped URI form of the String.
#
+ # @example
# "sweet+%26+sour".uri_unescape
# # => "sweet & sour"
#
def uri_unescape
CGI.unescape(self)
end
#
- # Returns the HTTP hexidecimal encoded form of the string.
+ # @return [String]
+ # The HTTP hexidecimal encoded form of the String.
#
+ # @example
# "hello".format_http
# # => "hello"
#
def format_http(options={})
format_bytes(options) { |b| "%%%x" % b }