Class: Georeference::GeoLocate::Request
- Inherits:
-
Object
- Object
- Georeference::GeoLocate::Request
- Defined in:
- app/models/georeference/geo_locate.rb
Constant Summary collapse
- 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
-
#request_param_string ⇒ Object
readonly
Returns the value of attribute request_param_string.
-
#request_params ⇒ Object
readonly
Returns the value of attribute request_params.
- #response ⇒ Georeference::GeoLocate::Response readonly
-
#succeeded ⇒ Object
Returns the value of attribute succeeded.
Instance Method Summary collapse
-
#build_param_string ⇒ Object
sets the @request_param_string attribute.
-
#initialize(request_params) ⇒ Request
constructor
A new instance of Request.
-
#locate ⇒ Object
sets the response attribute.
-
#request_string ⇒ String
Api request string.
-
#succeeded? ⇒ Boolean
True if request was successful.
Constructor Details
#initialize(request_params) ⇒ Request
Returns a new instance of Request.
280 281 282 283 |
# File 'app/models/georeference/geo_locate.rb', line 280 def initialize(request_params) @request_params = REQUEST_PARAMS.merge(request_params) @succeeded = nil end |
Instance Attribute Details
#request_param_string ⇒ Object (readonly)
Returns the value of attribute request_param_string.
277 278 279 |
# File 'app/models/georeference/geo_locate.rb', line 277 def request_param_string @request_param_string end |
#request_params ⇒ Object (readonly)
Returns the value of attribute request_params.
277 278 279 |
# File 'app/models/georeference/geo_locate.rb', line 277 def request_params @request_params end |
#response ⇒ Georeference::GeoLocate::Response (readonly)
307 308 309 |
# File 'app/models/georeference/geo_locate.rb', line 307 def response @response end |
#succeeded ⇒ Object
Returns the value of attribute succeeded.
276 277 278 |
# File 'app/models/georeference/geo_locate.rb', line 276 def succeeded @succeeded end |
Instance Method Details
#build_param_string ⇒ Object
sets the @request_param_string attribute.
291 292 293 |
# File 'app/models/georeference/geo_locate.rb', line 291 def build_param_string @request_param_string ||= @request_params.collect { |key, value| "#{key}=#{value}" }.join('&') end |
#locate ⇒ Object
sets the response attribute.
286 287 288 |
# File 'app/models/georeference/geo_locate.rb', line 286 def locate @response = Georeference::GeoLocate::Response.new(self) end |
#request_string ⇒ String
Returns api request string.
296 297 298 299 |
# File 'app/models/georeference/geo_locate.rb', line 296 def request_string build_param_string API_PATH + @request_param_string end |
#succeeded? ⇒ Boolean
Returns true if request was successful.
302 303 304 |
# File 'app/models/georeference/geo_locate.rb', line 302 def succeeded? @succeeded end |