Class: SunDawg::GeonamesClient
- Inherits:
-
Object
- Object
- SunDawg::GeonamesClient
- Defined in:
- lib/geonames_client.rb
Constant Summary collapse
- URL =
"http://ws.geonames.org"
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GeonamesClient
constructor
A new instance of GeonamesClient.
- #method_missing(signature, *args) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ GeonamesClient
Returns a new instance of GeonamesClient.
9 10 11 12 13 14 |
# File 'lib/geonames_client.rb', line 9 def initialize( = {}) [:json].nil? ? [:json] = true : nil [:camelize].nil? ? [:camelize] = false : nil [:username].nil? ? [:username] = "SunDawg" : nil @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(signature, *args) ⇒ Object
16 17 18 19 20 |
# File 'lib/geonames_client.rb', line 16 def method_missing(signature, *args) raise ArgumentError.new("must provide a hash of geoname parameters for first argument when calling web services [#{signature}] [#{args.inspect}]") if args.size < 1 || !args[0].is_a?(Hash) signature = smart_camelize(signature.to_s) unless @options[:camelize] do_http_call(service_resource(signature), args[0]) end |