Class: Spider::Site

Inherits:
Object show all
Defined in:
lib/spiderfw/site.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain, port, ssl_port = nil) ⇒ Site

Returns a new instance of Site.



9
10
11
12
13
# File 'lib/spiderfw/site.rb', line 9

def initialize(domain, port, ssl_port=nil)
    @domain = domain
    @port = port
    @ssl_port = ssl_port
end

Instance Attribute Details

#_autoObject

Returns the value of attribute _auto.



7
8
9
# File 'lib/spiderfw/site.rb', line 7

def _auto
  @_auto
end

#domainObject (readonly)

Returns the value of attribute domain.



4
5
6
# File 'lib/spiderfw/site.rb', line 4

def domain
  @domain
end

#portObject

Returns the value of attribute port.



5
6
7
# File 'lib/spiderfw/site.rb', line 5

def port
  @port
end

#ssl_portObject

Returns the value of attribute ssl_port.



6
7
8
# File 'lib/spiderfw/site.rb', line 6

def ssl_port
  @ssl_port
end

Class Method Details

.cache_fileObject



29
30
31
# File 'lib/spiderfw/site.rb', line 29

def self.cache_file
    @cache_file ||= File.join(Spider.paths[:var], 'site')
end

.load_cacheObject



21
22
23
24
25
26
27
# File 'lib/spiderfw/site.rb', line 21

def self.load_cache
    begin
        Marshal.restore(File.read(self.cache_file))
    rescue
        nil
    end
end

Instance Method Details

#auto?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/spiderfw/site.rb', line 37

def auto?
    @_auto
end

#save_cacheObject



15
16
17
18
19
# File 'lib/spiderfw/site.rb', line 15

def save_cache
    File.open(self.class.cache_file, 'w') do |f|
        f.puts(Marshal.dump(self))
    end
end

#ssl?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/spiderfw/site.rb', line 33

def ssl?
    @ssl_port
end

#ssl_to_sObject



47
48
49
50
51
# File 'lib/spiderfw/site.rb', line 47

def ssl_to_s
    s = "https://#{@domain}"
    s += ":#{@ssl_port}" if @ssl_port != 443
    s
end

#to_sObject



41
42
43
44
45
# File 'lib/spiderfw/site.rb', line 41

def to_s
    s = "http://#{@domain}"
    s += ":#{@port}" if @port != 80
    s
end