Class: SunDawg::GeonamesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/geonames_client.rb

Constant Summary collapse

URL =
"http://ws.geonames.org"

Instance Method Summary collapse

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(options = {})
  options[:json].nil? ? options[:json] = true : nil 
  options[:camelize].nil? ? options[:camelize] = false : nil
  options[:username].nil? ? options[:username] = "SunDawg" : nil
  @options = options
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(signature, *args) ⇒ Object

Raises:

  • (ArgumentError)


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