Class: Spider::Site
Instance Attribute Summary collapse
-
#_auto ⇒ Object
Returns the value of attribute _auto.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#port ⇒ Object
Returns the value of attribute port.
-
#ssl_port ⇒ Object
Returns the value of attribute ssl_port.
Class Method Summary collapse
Instance Method Summary collapse
- #auto? ⇒ Boolean
-
#initialize(domain, port, ssl_port = nil) ⇒ Site
constructor
A new instance of Site.
- #save_cache ⇒ Object
- #ssl? ⇒ Boolean
- #ssl_to_s ⇒ Object
- #to_s ⇒ Object
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
#_auto ⇒ Object
Returns the value of attribute _auto.
7 8 9 |
# File 'lib/spiderfw/site.rb', line 7 def _auto @_auto end |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
4 5 6 |
# File 'lib/spiderfw/site.rb', line 4 def domain @domain end |
#port ⇒ Object
Returns the value of attribute port.
5 6 7 |
# File 'lib/spiderfw/site.rb', line 5 def port @port end |
#ssl_port ⇒ Object
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_file ⇒ Object
29 30 31 |
# File 'lib/spiderfw/site.rb', line 29 def self.cache_file @cache_file ||= File.join(Spider.paths[:var], 'site') end |
.load_cache ⇒ Object
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
37 38 39 |
# File 'lib/spiderfw/site.rb', line 37 def auto? @_auto end |
#save_cache ⇒ Object
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
33 34 35 |
# File 'lib/spiderfw/site.rb', line 33 def ssl? @ssl_port end |
#ssl_to_s ⇒ Object
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_s ⇒ Object
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 |