Class: Georeference::GeoLocate::Request

Inherits:
Object
  • Object
show all
Defined in:
app/models/georeference/geo_locate.rb

Constant Summary

REQUEST_PARAMS =
{
  country:      nil, # name of a country 'USA', or Germany
  state:        nil, # 'IL', or 'illinois' (required in the United States)
  county:       nil, # supply as a parameter, returned as 'Adm='
  locality:     nil, # name of a place 'CHAMPAIGN' (or building, i.e. 'Eiffel Tower')
  enableH2O:    'false',
  hwyX:         'false',
  doUncert:     'true',
  doPoly:       'false',
  displacePoly: 'false',
  languageKey:  '0',
  fmt:          'json' # or geojson ?
}

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Request) initialize(request_params)

Returns a new instance of Request



226
227
228
229
# File 'app/models/georeference/geo_locate.rb', line 226

def initialize(request_params)
  @request_params = REQUEST_PARAMS.merge(request_params)
  @succeeded      = nil
end

Instance Attribute Details

- (Object) request_param_string (readonly)

Returns the value of attribute request_param_string



224
225
226
# File 'app/models/georeference/geo_locate.rb', line 224

def request_param_string
  @request_param_string
end

- (Object) request_params (readonly)

Returns the value of attribute request_params



224
225
226
# File 'app/models/georeference/geo_locate.rb', line 224

def request_params
  @request_params
end

- (Georeference::GeoLocate::Response) response (readonly)



253
254
255
# File 'app/models/georeference/geo_locate.rb', line 253

def response
  @response
end

- (Object) succeeded

Returns the value of attribute succeeded



223
224
225
# File 'app/models/georeference/geo_locate.rb', line 223

def succeeded
  @succeeded
end

Instance Method Details

- (Object) build_param_string

Returns sets the @request_param_string attribute.

Returns:

  • sets the @request_param_string attribute.



237
238
239
# File 'app/models/georeference/geo_locate.rb', line 237

def build_param_string
  @request_param_string ||= @request_params.collect { |key, value| "#{key}=#{value}" }.join('&')
end

- (Object) locate

Returns sets the response attribute.

Returns:

  • sets the response attribute.



232
233
234
# File 'app/models/georeference/geo_locate.rb', line 232

def locate
  @response = Georeference::GeoLocate::Response.new(self)
end

- (String) request_string

Returns api request string.

Returns:

  • (String)

    api request string.



242
243
244
245
# File 'app/models/georeference/geo_locate.rb', line 242

def request_string
  build_param_string
  URI_PATH + @request_param_string
end

- (Bool) succeeded?

Returns true if request was successful

Returns:

  • (Bool)

    true if request was successful



248
249
250
# File 'app/models/georeference/geo_locate.rb', line 248

def succeeded?
  @succeeded
end