Class: GeoNames::Base

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Base

Returns a new instance of Base.



14
15
16
17
18
19
# File 'lib/geo_names/base.rb', line 14

def initialize(params = {})
  @url = "#{configuration.api_base}#{controller_name_for(self.class)}"
  @params = {
    username: configuration.username
  }.merge(params)
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/geo_names/base.rb', line 8

def params
  @params
end

#urlObject (readonly)

Returns the value of attribute url.



8
9
10
# File 'lib/geo_names/base.rb', line 8

def url
  @url
end

Class Method Details

.search(params = {}) ⇒ Object



10
11
12
# File 'lib/geo_names/base.rb', line 10

def self.search(params = {})
  new(params).call
end

Instance Method Details

#callObject



21
22
23
24
# File 'lib/geo_names/base.rb', line 21

def call
  result = make_request
  parse(result)
end