Class: Source

Inherits:
Object
  • Object
show all
Defined in:
lib/source.rb

Overview

Created by me on 2007-12-28.

Copyright (c) 2007. All pwnage reserved.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#fullObject

Returns the value of attribute full


8
9
10
# File 'lib/source.rb', line 8

def full
  @full
end

#hostObject

Returns the value of attribute host


8
9
10
# File 'lib/source.rb', line 8

def host
  @host
end

#lengthObject

Returns the value of attribute length


8
9
10
# File 'lib/source.rb', line 8

def length
  @length
end

#pageObject

Returns the value of attribute page


8
9
10
# File 'lib/source.rb', line 8

def page
  @page
end

#pathObject

Returns the value of attribute path


8
9
10
# File 'lib/source.rb', line 8

def path
  @path
end

#portObject

Returns the value of attribute port


8
9
10
# File 'lib/source.rb', line 8

def port
  @port
end

#schemeObject

Returns the value of attribute scheme


8
9
10
# File 'lib/source.rb', line 8

def scheme
  @scheme
end

Instance Method Details

#finishObject


41
42
43
# File 'lib/source.rb', line 41

def finish
  @prefix.clean
end

#startObject Also known as: roll


35
36
37
38
# File 'lib/source.rb', line 35

def start
  @prefix.prep
  @prefix.fetch
end