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 ?
}.freeze

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Request) initialize(request_params)

Returns a new instance of Request

Parameters:

  • request_params (ActionController::Parameters)


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

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



245
246
247
# File 'app/models/georeference/geo_locate.rb', line 245

def request_param_string
  @request_param_string
end

- (Object) request_params (readonly)

Returns the value of attribute request_params



245
246
247
# File 'app/models/georeference/geo_locate.rb', line 245

def request_params
  @request_params
end

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



275
276
277
# File 'app/models/georeference/geo_locate.rb', line 275

def response
  @response
end

- (Object) succeeded

Returns the value of attribute succeeded



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

def succeeded
  @succeeded
end

Instance Method Details

- (Object) build_param_string

sets the @request_param_string attribute.



259
260
261
# File 'app/models/georeference/geo_locate.rb', line 259

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

- (Object) locate

sets the response attribute.



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

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

- (String) request_string

Returns api request string.

Returns:

  • (String)

    api request string.



264
265
266
267
# File 'app/models/georeference/geo_locate.rb', line 264

def request_string
  build_param_string
  URI_PATH + @request_param_string
end

- (Boolean) succeeded?

Returns true if request was successful

Returns:

  • (Boolean)

    true if request was successful



270
271
272
# File 'app/models/georeference/geo_locate.rb', line 270

def succeeded?
  @succeeded
end