class GeoScraper

Constants

VERSION

Public Class Methods

new(url) click to toggle source
# File lib/GeoScraper/core.rb, line 11
def initialize url
  @url = url
  @@pattern.each do |pattern|
    if @matches = pattern[0].match(@url)
      extend Object.const_get("GeoScraper::" + pattern[1])
      @matches = Regexp.last_match
      @result = scrape
      break
    end
  end
end

Public Instance Methods

get_doc(uri) click to toggle source
# File lib/GeoScraper/core.rb, line 23
def get_doc uri
  Nokogiri::HTML.parse(open(uri, "User-Agent" => "Mozilla/5.0 Geo Scraper").read)
end
has_data?() click to toggle source
# File lib/GeoScraper/core.rb, line 27
def has_data?
  !@result.nil?
end
lat() click to toggle source
# File lib/GeoScraper/core.rb, line 37
def lat
  if  has_data?
    @result["latitude"].to_f
  end
end
lon() click to toggle source
# File lib/GeoScraper/core.rb, line 31
def lon
  if  has_data?
    @result["longitude"].to_f
  end
end