Class: Xapian::Indexer::Spider::Fetch

Inherits:
Object
  • Object
show all
Defined in:
lib/xapian/indexer/spider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database, controller, link) ⇒ Fetch

Returns a new instance of Fetch.



57
58
59
60
61
62
63
64
# File 'lib/xapian/indexer/spider.rb', line 57

def initialize(database, controller, link)
	@database = database
	@controller = controller
	
	@document = false
	@current_resource = controller.create(link)
	@archived_resource = false
end

Instance Attribute Details

#controllerObject (readonly)

Returns the value of attribute controller.



67
68
69
# File 'lib/xapian/indexer/spider.rb', line 67

def controller
  @controller
end

#current_resourceObject (readonly)

Returns the value of attribute current_resource.



68
69
70
# File 'lib/xapian/indexer/spider.rb', line 68

def current_resource
  @current_resource
end

#databaseObject (readonly)

Returns the value of attribute database.



66
67
68
# File 'lib/xapian/indexer/spider.rb', line 66

def database
  @database
end

Instance Method Details

#archived_resourceObject



84
85
86
87
88
89
90
91
92
# File 'lib/xapian/indexer/spider.rb', line 84

def archived_resource
	if @archived_resource === false
		if document
			@archived_resource = @controller.recreate(document.data)
		end
	end
	
	return @archived_resource
end

#documentObject



70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/xapian/indexer/spider.rb', line 70

def document
	if @document === false
		postlist = @database.postlist(@current_resource.name_digest)

		if postlist.size > 0
			@document = @database.document(postlist[0].docid)
		else
			@document = nil
		end
	end
	
	return @document
end


94
95
96
97
98
99
100
101
102
103
# File 'lib/xapian/indexer/spider.rb', line 94

def links
	#$stderr.puts "current_resource.links = #{@current_resource.links.inspect}" if @current_resource
	#$stderr.puts "archived_resource.links = #{archived_resource.links.inspect}" if archived_resource
	
	if @current_resource.fetched?
		@current_resource.links
	elsif archived_resource
		archived_resource.links
	end
end