diff options
author | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-04 18:05:50 +0000 |
---|---|---|
committer | drbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-04 18:05:50 +0000 |
commit | 52c034aecb365c6cf2a41b8648c3e87fb335fdaf (patch) | |
tree | 199813273b1cd9a90b40e3dc797303d0e5f8c67b /lib/open-uri.rb | |
parent | 4db2df633cc784c40e21b3df38fe9a6dd1b0ff0b (diff) | |
download | ruby-52c034aecb365c6cf2a41b8648c3e87fb335fdaf.tar.gz |
Documentation cleanup.
Includes patches by Hugh Sasse:
* ping.rb
* weakref.rb
* mailread.rb
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10668 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/open-uri.rb')
-rw-r--r-- | lib/open-uri.rb | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/lib/open-uri.rb b/lib/open-uri.rb index e0d385e663..56c78f0468 100644 --- a/lib/open-uri.rb +++ b/lib/open-uri.rb @@ -1,59 +1,3 @@ -#= open-uri.rb -# -#open-uri.rb is easy-to-use wrapper for net/http, net/https and net/ftp. -# -#== Example -# -#It is possible to open http/https/ftp URL as usual a file: -# -# open("http://www.ruby-lang.org/") {|f| -# f.each_line {|line| p line} -# } -# -#The opened file has several methods for meta information as follows since -#it is extended by OpenURI::Meta. -# -# open("http://www.ruby-lang.org/en") {|f| -# f.each_line {|line| p line} -# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/> -# p f.content_type # "text/html" -# p f.charset # "iso-8859-1" -# p f.content_encoding # [] -# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002 -# } -# -#Additional header fields can be specified by an optional hash argument. -# -# open("http://www.ruby-lang.org/en/", -# "User-Agent" => "Ruby/#{RUBY_VERSION}", -# "From" => "foo@bar.invalid", -# "Referer" => "http://www.ruby-lang.org/") {|f| -# ... -# } -# -#The environment variables such as http_proxy, https_proxy and ftp_proxy -#are in effect by default. :proxy => nil disables proxy. -# -# open("http://www.ruby-lang.org/en/raa.html", -# :proxy => nil) {|f| -# ... -# } -# -#URI objects can be opened in similar way. -# -# uri = URI.parse("http://www.ruby-lang.org/en/") -# uri.open {|f| -# ... -# } -# -#URI objects can be read directly. -#The returned string is also extended by OpenURI::Meta. -# -# str = uri.read -# p str.base_uri -# -#Author:: Tanaka Akira <akr@m17n.org> - require 'uri' require 'stringio' require 'time' @@ -91,6 +35,59 @@ module Kernel module_function :open end +# OpenURI is an easy-to-use wrapper for net/http, net/https and net/ftp. +# +#== Example +# +# It is possible to open http/https/ftp URL as usual like opening a file: +# +# open("http://www.ruby-lang.org/") {|f| +# f.each_line {|line| p line} +# } +# +# The opened file has several methods for meta information as follows since +# it is extended by OpenURI::Meta. +# +# open("http://www.ruby-lang.org/en") {|f| +# f.each_line {|line| p line} +# p f.base_uri # <URI::HTTP:0x40e6ef2 URL:http://www.ruby-lang.org/en/> +# p f.content_type # "text/html" +# p f.charset # "iso-8859-1" +# p f.content_encoding # [] +# p f.last_modified # Thu Dec 05 02:45:02 UTC 2002 +# } +# +# Additional header fields can be specified by an optional hash argument. +# +# open("http://www.ruby-lang.org/en/", +# "User-Agent" => "Ruby/#{RUBY_VERSION}", +# "From" => "foo@bar.invalid", +# "Referer" => "http://www.ruby-lang.org/") {|f| +# # ... +# } +# +# The environment variables such as http_proxy, https_proxy and ftp_proxy +# are in effect by default. :proxy => nil disables proxy. +# +# open("http://www.ruby-lang.org/en/raa.html", :proxy => nil) {|f| +# # ... +# } +# +# URI objects can be opened in a similar way. +# +# uri = URI.parse("http://www.ruby-lang.org/en/") +# uri.open {|f| +# # ... +# } +# +# URI objects can be read directly. The returned string is also extended by +# OpenURI::Meta. +# +# str = uri.read +# p str.base_uri +# +# Author:: Tanaka Akira <akr@m17n.org> + module OpenURI Options = { :proxy => true, |