Class: Source
- Inherits:
-
Object
- Object
- Source
- Defined in:
- lib/source.rb
Overview
Created by me on 2007-12-28.
Copyright (c) 2007. All pwnage reserved.
Instance Attribute Summary collapse
-
#full ⇒ Object
Returns the value of attribute full.
-
#host ⇒ Object
Returns the value of attribute host.
-
#length ⇒ Object
Returns the value of attribute length.
-
#page ⇒ Object
Returns the value of attribute page.
-
#path ⇒ Object
Returns the value of attribute path.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
Instance Method Summary collapse
- #finish ⇒ Object
-
#initialize(uri_obj, opts) ⇒ Source
constructor
A new instance of Source.
- #start ⇒ Object (also: #roll)
Constructor Details
#initialize(uri_obj, opts) ⇒ Source
Returns a new instance of Source.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/source.rb', line 10 def initialize(uri_obj, opts) @uri = uri_obj @host = uri_obj.host @port = uri_obj.port @scheme = uri_obj.scheme @page = (uri_obj.path =~ /^$/ ? "/" : uri_obj.path) @full = @scheme + '://' + @host + @page @in = opts[:in] @out = opts[:out] opts[:out] = opts[:out] || (File.basename(@page) =~ /^\/$/ ? 'default' : File.basename(@page)) opts[:out] = (File.directory?(opts[:out]) ? File.join(opts[:out], File.basename(@page)) : opts[:out]) case @scheme when "http" then @prefix = HTTP when "https" then @prefix = HTTPS when "ftp" then @prefix = FTP when "torrent" then @prefix = Torrent else abort "Unknown URL scheme!\nsnoopy --help for help and usage" end prep(opts) end |
Instance Attribute Details
#full ⇒ Object
Returns the value of attribute full.
8 9 10 |
# File 'lib/source.rb', line 8 def full @full end |
#host ⇒ Object
Returns the value of attribute host.
8 9 10 |
# File 'lib/source.rb', line 8 def host @host end |
#length ⇒ Object
Returns the value of attribute length.
8 9 10 |
# File 'lib/source.rb', line 8 def length @length end |
#page ⇒ Object
Returns the value of attribute page.
8 9 10 |
# File 'lib/source.rb', line 8 def page @page end |
#path ⇒ Object
Returns the value of attribute path.
8 9 10 |
# File 'lib/source.rb', line 8 def path @path end |
#port ⇒ Object
Returns the value of attribute port.
8 9 10 |
# File 'lib/source.rb', line 8 def port @port end |
#scheme ⇒ Object
Returns the value of attribute scheme.
8 9 10 |
# File 'lib/source.rb', line 8 def scheme @scheme end |
Instance Method Details
#finish ⇒ Object
41 42 43 |
# File 'lib/source.rb', line 41 def finish @prefix.clean end |
#start ⇒ Object Also known as: roll
35 36 37 38 |
# File 'lib/source.rb', line 35 def start @prefix.prep @prefix.fetch end |