class ReverseGeo

Public Class Methods

new(file = nil) click to toggle source
# File lib/reverse_geo/reverse_geo.rb, line 7
def initialize(file = nil)
  file ||= File.join(File.dirname(__FILE__), @@default_shapefile)
  raise ArgumentError, 'Did not supply a valid geojson file.' unless File.exist?(file)

  @factory = RGeo::Geos.factory(srid: 4326)
  @countries = RGeo::GeoJSON.decode(File.open(file).read, :json_parser => :json, :geo_factory => @factory)
end

Public Instance Methods

country(opts = {}) click to toggle source
# File lib/reverse_geo/reverse_geo.rb, line 19
def country(opts = {})
  country_search('Country', opts)
end
country_code(opts = {}) click to toggle source
# File lib/reverse_geo/reverse_geo.rb, line 15
def country_code(opts = {})
  country_search('ISO_A3', opts)
end

Private Instance Methods