Class: OpenWeather::Client
- Inherits:
-
Object
- Object
- OpenWeather::Client
- Includes:
- HTTParty
- Defined in:
- lib/OpenWeather.rb
Instance Attribute Summary collapse
-
#data_format ⇒ Object
Returns the value of attribute data_format.
-
#units_format ⇒ Object
Returns the value of attribute units_format.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Client
constructor
Open Weather Map Client.
- #load_file(file) ⇒ Object
- #unload_file ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Client
Open Weather Map Client
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/OpenWeather.rb', line 27 def initialize( opts = {} ) = {url: "http://api.openweathermap.org/data/2.5", useragent: "Open Weather Ruby v#{VERSION}"}.merge opts @baseurl = [:url] @headers = {'User-Agent' => [:useragent]} # For HTTParty self.class.base_uri [:url] self.class.headers @headers @units_format = 'metric' @data_format = 'json' @api_key = [:api_key] if [:api_key] end |
Instance Attribute Details
#data_format ⇒ Object
Returns the value of attribute data_format.
19 20 21 |
# File 'lib/OpenWeather.rb', line 19 def data_format @data_format end |
#units_format ⇒ Object
Returns the value of attribute units_format.
19 20 21 |
# File 'lib/OpenWeather.rb', line 19 def units_format @units_format end |
Instance Method Details
#load_file(file) ⇒ Object
40 41 42 |
# File 'lib/OpenWeather.rb', line 40 def load_file(file) @city_file = file if File.exist? file end |
#unload_file ⇒ Object
44 45 46 |
# File 'lib/OpenWeather.rb', line 44 def unload_file @city_file = nil end |