Class: Ropenweather::Client

Inherits:
Object
  • Object
show all
Includes:
Agent
Defined in:
lib/ropenweather/client.rb

Constant Summary collapse

DEFAULT_BASE_URI =
'http://api.openweathermap.org/data/2.5'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Agent

#execute

Constructor Details

#initialize(api_key:, base_uri: DEFAULT_BASE_URI, lang: 'en', units: 'metric') ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
# File 'lib/ropenweather/client.rb', line 13

def initialize(api_key:, base_uri: DEFAULT_BASE_URI, lang: 'en', units: 'metric')
  self.api_key = api_key
  self.base_uri = base_uri
  self.lang = lang
  self.units = units
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



11
12
13
# File 'lib/ropenweather/client.rb', line 11

def api_key
  @api_key
end

#base_uriObject

Returns the value of attribute base_uri.



11
12
13
# File 'lib/ropenweather/client.rb', line 11

def base_uri
  @base_uri
end

#langObject

Returns the value of attribute lang.



11
12
13
# File 'lib/ropenweather/client.rb', line 11

def lang
  @lang
end

#unitsObject

Returns the value of attribute units.



11
12
13
# File 'lib/ropenweather/client.rb', line 11

def units
  @units
end

Instance Method Details

#current_weather(city:, action: 'weather') ⇒ Object



20
21
22
# File 'lib/ropenweather/client.rb', line 20

def current_weather(city:, action: 'weather')
  execute(city: city, action: action, config: config_params)
end