Class: OpenWeatherClient::Configuration
- Inherits:
-
Object
- Object
- OpenWeatherClient::Configuration
- Defined in:
- lib/open_weather_client/configuration.rb
Overview
Configuratin of OpenWeatherClient
Instance Attribute Summary collapse
-
#api_version ⇒ Object
- String
-
Used api version.
-
#appid ⇒ Object
- String
-
API key to access OpenWeatherMap.
-
#caching ⇒ Object
Caching method.
-
#lang ⇒ Object
- String
-
Requested language of the result.
-
#max_memory_entries ⇒ Object
- Integer
-
Maximum allowed number of entries when using caching method :memory.
-
#spatial_quantization ⇒ Object
- Proc
-
Quantization of latitude and longitude.
-
#units ⇒ Object
- String
-
Requested units of the result.
-
#url ⇒ Object
- String
-
Base URL of the requests to OpenWeatherMap.
-
#user_agent ⇒ Object
- String
-
User-Agent of the requests made to OpenWeatherMap.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
Initialize a new Configuration with the default settings.
-
#load_from_rails_credentials ⇒ Object
Load appid from Rails credentials.
Constructor Details
#initialize ⇒ Configuration
Initialize a new Configuration with the default settings
28 29 30 31 32 33 34 35 36 |
# File 'lib/open_weather_client/configuration.rb', line 28 def initialize @api_version = :v25 @caching = OpenWeatherClient::Caching.new @lang = 'de' @max_memory_entries = 10_000 @units = 'metric' @url = 'https://api.openweathermap.org/data' @user_agent = "Open Weather Client/#{OpenWeatherClient::VERSION}" end |
Instance Attribute Details
#api_version ⇒ Object
- String
-
Used api version. One of :v25, :v30. Default :v25
8 9 10 |
# File 'lib/open_weather_client/configuration.rb', line 8 def api_version @api_version end |
#appid ⇒ Object
- String
-
API key to access OpenWeatherMap
10 11 12 |
# File 'lib/open_weather_client/configuration.rb', line 10 def appid @appid end |
#caching ⇒ Object
Caching method. One of :none, :memory
12 13 14 |
# File 'lib/open_weather_client/configuration.rb', line 12 def caching @caching end |
#lang ⇒ Object
- String
-
Requested language of the result
14 15 16 |
# File 'lib/open_weather_client/configuration.rb', line 14 def lang @lang end |
#max_memory_entries ⇒ Object
- Integer
-
Maximum allowed number of entries when using caching method :memory
16 17 18 |
# File 'lib/open_weather_client/configuration.rb', line 16 def max_memory_entries @max_memory_entries end |
#spatial_quantization ⇒ Object
- Proc
-
Quantization of latitude and longitude
18 19 20 |
# File 'lib/open_weather_client/configuration.rb', line 18 def spatial_quantization @spatial_quantization end |
#units ⇒ Object
- String
-
Requested units of the result
20 21 22 |
# File 'lib/open_weather_client/configuration.rb', line 20 def units @units end |
#url ⇒ Object
- String
-
Base URL of the requests to OpenWeatherMap
22 23 24 |
# File 'lib/open_weather_client/configuration.rb', line 22 def url @url end |
#user_agent ⇒ Object
- String
-
User-Agent of the requests made to OpenWeatherMap
24 25 26 |
# File 'lib/open_weather_client/configuration.rb', line 24 def user_agent @user_agent end |
Instance Method Details
#load_from_rails_credentials ⇒ Object
Load appid from Rails credentials
Load the appid from Rails credentials using the top-level key ‘open_weather_client’
52 53 54 55 56 57 |
# File 'lib/open_weather_client/configuration.rb', line 52 def load_from_rails_credentials raise 'This method is only available in Ruby on Rails.' unless defined? Rails settings = Rails.application.credentials.open_weather_client! self.appid = settings[:appid] end |