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.
| 302 303 304 305 | # File 'app/models/georeference/geo_locate.rb', line 302 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.
| 299 300 301 | # File 'app/models/georeference/geo_locate.rb', line 299 def request_param_string @request_param_string end | 
#request_params ⇒ Object (readonly)
Returns the value of attribute request_params.
| 299 300 301 | # File 'app/models/georeference/geo_locate.rb', line 299 def request_params @request_params end | 
#response ⇒ Georeference::GeoLocate::Response (readonly)
| 329 330 331 | # File 'app/models/georeference/geo_locate.rb', line 329 def response @response end | 
#succeeded ⇒ Object
Returns the value of attribute succeeded.
| 298 299 300 | # File 'app/models/georeference/geo_locate.rb', line 298 def succeeded @succeeded end | 
Instance Method Details
#build_param_string ⇒ Object
sets the @request_param_string attribute.
| 313 314 315 | # File 'app/models/georeference/geo_locate.rb', line 313 def build_param_string @request_param_string ||= @request_params.collect { |key, value| "#{key}=#{value}" }.join('&') end | 
#locate ⇒ Object
sets the response attribute.
| 308 309 310 | # File 'app/models/georeference/geo_locate.rb', line 308 def locate @response = Georeference::GeoLocate::Response.new(self) end | 
#request_string ⇒ String
Returns api request string.
| 318 319 320 321 | # File 'app/models/georeference/geo_locate.rb', line 318 def request_string build_param_string API_PATH + @request_param_string end | 
#succeeded? ⇒ Boolean
Returns true if request was successful.
| 324 325 326 | # File 'app/models/georeference/geo_locate.rb', line 324 def succeeded? @succeeded end |