Class: Usenet
- Inherits:
-
Object
- Object
- Usenet
- Includes:
- Searchy
- Defined in:
- lib/esearchy/OtherEngines/usenet.rb
Instance Attribute Summary collapse
-
#emails ⇒ Object
Returns the value of attribute emails.
Instance Method Summary collapse
-
#initialize(maxhits = 0) ⇒ Usenet
constructor
A new instance of Usenet.
- #search(query) ⇒ Object
Methods included from Searchy
#clean, #fix, #hash_url, #maxhits=, #print_emails, #search_depth, #search_docs, #search_emails, #search_office_xml, #search_pdfs, #search_txts
Constructor Details
#initialize(maxhits = 0) ⇒ Usenet
Returns a new instance of Usenet.
8 9 10 11 12 |
# File 'lib/esearchy/OtherEngines/usenet.rb', line 8 def initialize(maxhits=0) @totalhits = maxhits @emails = [] @lock = Mutex.new end |
Instance Attribute Details
#emails ⇒ Object
Returns the value of attribute emails.
13 14 15 |
# File 'lib/esearchy/OtherEngines/usenet.rb', line 13 def emails @emails end |
Instance Method Details
#search(query) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/esearchy/OtherEngines/usenet.rb', line 15 def search(query) @query = query http = Net::HTTP.new("usenet-addresses.mit.edu",80) begin http.start do |http| request = Net::HTTP::Get.new( "/cgi-bin/udb?T=#{@query}&G=&S=&N=&O=&M=500", {'User-Agent' => UserAgent::fetch}) response = http.request(request) case response when Net::HTTPSuccess, Net::HTTPRedirection ESearchy::LOG.puts "Searching #{self.class}" search_emails(response.body) else return response.error! end end rescue Net::HTTPFatalError ESearchy::LOG.puts "Error: Something went wrong with the HTTP request" end end |