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



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

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



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

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

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



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

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