Class: GeocoderSimplified

Inherits:
Object
  • Object
show all
Defined in:
lib/geocoder-simplified/base.rb,
lib/geocoder-simplified/version.rb

Overview

monkeypatch ruby from the rails underscore addition to String

Defined Under Namespace

Classes: Configuration, GeocoderApi

Constant Summary collapse

POSTFIX =
"Geocode"
UNLIMITED_CALLS =
Util::MAX_INT32
VERSION =

NON_FUNCTIONAL 0.0.0.x level changes for changes to documentation and formatting or functionally equivalent sturctural changes PATCH 0.0.x level changes for implementation level detail changes, such as small bug fixes MINOR 0.x.0 level changes for any backwards compatible API changes, such as new functionality/features MAJOR x.0.0 level changes for backwards incompatible

"1.0.0.1"
@@api_list =

Attach the default goecoding apis, _in order_. The first added will be the first tried.

[]

Class Method Summary collapse

Class Method Details

.get_countsObject

@@api_list.each{|api| puts “#{api.count}:#apiapi.symbol”}



74
75
76
# File 'lib/geocoder-simplified/base.rb', line 74

def get_counts
  @@api_list.each.inject({}){|h,api| h.update(api.symbol => api.count)}
end

.locate(place_name) ⇒ Object



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/geocoder-simplified/base.rb', line 78

def locate(place_name)
  latitude = 0.0
  longitude = 0.0
  api_name = nil

  @@api_list.each do |api|
    if api.counter.increment
      latitude, longitude = api.locate(place_name)
      if not (latitude == 0.0 and longitude == 0.0)
        api_name = api.symbol
      end
    end
    break if not (latitude == 0.0 and longitude == 0.0)
  end

  return latitude, longitude, api_name
end