Class: EarthTools::Lookup::Base
- Inherits:
-
Object
- Object
- EarthTools::Lookup::Base
- Defined in:
- lib/earth_tools/lookup/base.rb
Overview
Base lookup object.
Direct Known Subclasses
Instance Method Summary collapse
-
#search(*options) ⇒ EarthTools::Result?
Query the Earth Tools service and return a EarthTools::Result object.
Instance Method Details
#search(*options) ⇒ EarthTools::Result?
Query the Earth Tools service and return a EarthTools::Result object.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/earth_tools/lookup/base.rb', line 16 def search(*) begin Timeout::timeout(EarthTools::Configuration.timeout) do uri = query() if cache && results = cache[uri] # Boom, cached else # Not cached, so go get the data raw_results = retrieve(uri) results = parse_xml(raw_results) # Save results to cache, if available cache(uri, results) if cache && results end results end rescue Timeout::Error => err raise_error(err) or warn "Earth Tools API took too long to respond. See EarthTools::Configuration to set the timeout time (currently set to #{EarthTools::Configuration.timeout} seconds)." end end |