Class: Google::Geo::Response
- Inherits:
-
Object
- Object
- Google::Geo::Response
- Includes:
- Parser
- Defined in:
- lib/google/geo/response.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#geo ⇒ Object
readonly
Returns the value of attribute geo.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#xml ⇒ Object
readonly
Returns the value of attribute xml.
Instance Method Summary collapse
- #addresses ⇒ Object
-
#initialize(geo, params) ⇒ Response
constructor
:nodoc.
Methods included from Parser
Constructor Details
#initialize(geo, params) ⇒ Response
:nodoc
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/google/geo/response.rb', line 12 def initialize(geo, params) #:nodoc @geo = geo @params = params @xml = open(params.to_uri).read @query = fetch(:name) @status = fetch(:code).to_i case @status when 200 then # Success when 500 then raise ServerError, "Unknown error from Google's server" when 601 then raise MissingAddressError, "Missing address" when 602 then raise UnknownAddressError, "Unknown address: #{@query}" when 603 then raise UnavailableAddressError, "Unavailable address: #{@query}" when 610 then raise InvalidMapKeyError, "Invalid map key: #{@geo.key}" when 620 then raise TooManyQueriesError, "Too many queries for map key: #{@geo.key}" when 400 then raise BadRequestError, "Bad request: #{@status}" else raise UnknownError, "Unknown error: #{@status}" end @placemarks = @xml.scan %r{<Placemark(?: id="p\d+")?>.+?</Placemark>}m end |
Instance Attribute Details
#geo ⇒ Object (readonly)
Returns the value of attribute geo.
10 11 12 |
# File 'lib/google/geo/response.rb', line 10 def geo @geo end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
10 11 12 |
# File 'lib/google/geo/response.rb', line 10 def params @params end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
10 11 12 |
# File 'lib/google/geo/response.rb', line 10 def query @query end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/google/geo/response.rb', line 10 def status @status end |
#xml ⇒ Object (readonly)
Returns the value of attribute xml.
10 11 12 |
# File 'lib/google/geo/response.rb', line 10 def xml @xml end |