Class: GeonamesClient::ServiceDefinition
- Inherits:
-
Object
- Object
- GeonamesClient::ServiceDefinition
- Defined in:
- lib/geonames_client/service_definition.rb
Class Method Summary collapse
Instance Method Summary collapse
- #base_uri ⇒ Object
- #full_nearby_streets_uri(params = {}) ⇒ Object
- #latitude_parameter ⇒ Object
- #longitude_parameter ⇒ Object
- #nearby_streets_base_path(format = :xml) ⇒ Object
- #nearby_streets_json_path ⇒ Object
- #nearby_streets_path ⇒ Object
- #username_parameter ⇒ Object
Class Method Details
.address ⇒ Object
4 5 6 |
# File 'lib/geonames_client/service_definition.rb', line 4 def self.address 'api.geonames.org' end |
Instance Method Details
#base_uri ⇒ Object
8 9 10 |
# File 'lib/geonames_client/service_definition.rb', line 8 def base_uri ['http://', self.class.address].join end |
#full_nearby_streets_uri(params = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/geonames_client/service_definition.rb', line 41 def full_nearby_streets_uri( params={} ) expected_parameters.each do |p| raise "Please provide the :#{p} parameter" unless params.has_key?( p.to_sym ) end format = params.delete( :format ) || default_format [nearby_streets_base_path( format ), query_string( params )].join '?' end |
#latitude_parameter ⇒ Object
20 21 22 |
# File 'lib/geonames_client/service_definition.rb', line 20 def latitude_parameter 'lat' end |
#longitude_parameter ⇒ Object
24 25 26 |
# File 'lib/geonames_client/service_definition.rb', line 24 def longitude_parameter 'lng' end |
#nearby_streets_base_path(format = :xml) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/geonames_client/service_definition.rb', line 32 def nearby_streets_base_path( format=:xml ) format = format.to_sym raise "Invalid format: expected one of #{available_formats.join( ', ' )}" unless available_formats.include?( format ) return [base_uri, format == :xml ? nearby_streets_path : nearby_streets_json_path].join '' end |
#nearby_streets_json_path ⇒ Object
16 17 18 |
# File 'lib/geonames_client/service_definition.rb', line 16 def nearby_streets_json_path '/findNearbyStreetsJSON' end |
#nearby_streets_path ⇒ Object
12 13 14 |
# File 'lib/geonames_client/service_definition.rb', line 12 def nearby_streets_path '/findNearbyStreets' end |
#username_parameter ⇒ Object
28 29 30 |
# File 'lib/geonames_client/service_definition.rb', line 28 def username_parameter 'username' end |