Class: Wiki

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

Instance Method Summary collapse

Constructor Details

#initializeWiki

Returns a new instance of Wiki.



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

def initialize()
@@agent = Mechanize.new
end

Instance Method Details

#fetch_url(url) ⇒ Object



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

def fetch_url(url)
	begin
		page_data = @@agent.get url
		return page_data.body
	rescue => e
		e.message
	end
end

#search_suggestions(name, options = {}) ⇒ Object



15
16
17
18
# File 'lib/wiki_fetch.rb', line 15

def search_suggestions(name, options = {})
	url = UrlFormatter.create_url({:name => name, :method => "search_suggestions", :options => options})
	fetch_url(url)
end

#search_title(name, options = {}) ⇒ Object



10
11
12
13
# File 'lib/wiki_fetch.rb', line 10

def search_title(name, options = {})
	url = UrlFormatter.create_url({:name => name, :method => "search_title", :options => options})
	fetch_url(url)
end