class Ubi::Consultor::Base

Base for araneas (spiders)

Constants

HEADERS

Public Class Methods

inherited(base) click to toggle source
# File lib/ubi/consultor.rb, line 40
def inherited(base)
  Ubi.araneas << base
  # puts "Using aranea #{base}"
end
name() click to toggle source

Human-readable name of the aranea

# File lib/ubi/consultor.rb, line 48
def name
  fail "Not implemented by #{self}"
end
new(thema) click to toggle source
# File lib/ubi/consultor.rb, line 7
def initialize(thema)
  @thema = thema
end
url() click to toggle source

Url to query

# File lib/ubi/consultor.rb, line 55
def url
  fail "Not implemented by #{self}"
end

Public Instance Methods

datum() click to toggle source
# File lib/ubi/consultor.rb, line 23
def datum
  @datum ||= Ubi::Datum.new(parser(request), words, links)
end
parser(chunk) click to toggle source
# File lib/ubi/consultor.rb, line 19
def parser(chunk)
  Nokogiri::HTML(chunk)
end
query_url() click to toggle source
# File lib/ubi/consultor.rb, line 11
def query_url
  self.class.url + query.to_query
end
request(opts = {}) click to toggle source

Make an HTTP(S) request to a geocoding API and return the response object.

# File lib/ubi/consultor.rb, line 31
def request(opts = {})
  timeout(10) do
    uri = URI.parse(query_url)
    puts "#{self} working on `#{@thema}` (#{query_url}) #{opts}"
    uri.open(HEADERS).read
  end
end