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.



50
51
52
53
54
55
56
57
# File 'lib/xapian/indexer/spider.rb', line 50

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.



60
61
62
# File 'lib/xapian/indexer/spider.rb', line 60

def controller
  @controller
end

#current_resourceObject (readonly)

Returns the value of attribute current_resource.



61
62
63
# File 'lib/xapian/indexer/spider.rb', line 61

def current_resource
  @current_resource
end

#databaseObject (readonly)

Returns the value of attribute database.



59
60
61
# File 'lib/xapian/indexer/spider.rb', line 59

def database
  @database
end

Instance Method Details

#archived_resourceObject



77
78
79
80
81
82
83
84
85
# File 'lib/xapian/indexer/spider.rb', line 77

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

#documentObject



63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/xapian/indexer/spider.rb', line 63

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


87
88
89
90
91
92
93
94
95
96
# File 'lib/xapian/indexer/spider.rb', line 87

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