module WGET

URLopen 1999 by yoshidam

TODO: This module should be writen by Ruby instead of wget/lynx.

Constants

PARAM

Public Class Methods

open(url, *rest) click to toggle source
# File lib/wget.rb, line 14
def open(url, *rest)
    raise TypeError.new("wrong argument type #{url.inspect}" +
                        " (expected String)") if url.class != String

  if url =~ /^\/|^\./ || (url !~ /^http:|^ftp:/ && FileTest.exist?(url))
    File::open(url, *rest)
  else
    ENV['http_proxy'] = PARAM['http_proxy'] if PARAM['http_proxy']
    ENV['ftp_proxy'] = PARAM['ftp_proxy'] if PARAM['ftp_proxy']
    IO::popen(PARAM['wget'] + ' ' + PARAM['opts'] + ' ' + url)
  end
end

Private Instance Methods

open(url, *rest) click to toggle source
# File lib/wget.rb, line 14
def open(url, *rest)
    raise TypeError.new("wrong argument type #{url.inspect}" +
                        " (expected String)") if url.class != String

  if url =~ /^\/|^\./ || (url !~ /^http:|^ftp:/ && FileTest.exist?(url))
    File::open(url, *rest)
  else
    ENV['http_proxy'] = PARAM['http_proxy'] if PARAM['http_proxy']
    ENV['ftp_proxy'] = PARAM['ftp_proxy'] if PARAM['ftp_proxy']
    IO::popen(PARAM['wget'] + ' ' + PARAM['opts'] + ' ' + url)
  end
end