Class: CanLII::Configuration
- Inherits:
-
Object
- Object
- CanLII::Configuration
- Defined in:
- lib/canlii/configuration.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#language ⇒ Object
Returns the value of attribute language.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
7 8 9 10 11 12 13 |
# File 'lib/canlii/configuration.rb', line 7 def initialize @base_url = "https://api.canlii.org/v1" @language = "en" @api_key = ENV.fetch("CANLII_API_KEY", nil) @logger = Logger.new($stdout) @timeout = 30 # Default 30 seconds end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
5 6 7 |
# File 'lib/canlii/configuration.rb', line 5 def api_key @api_key end |
#base_url ⇒ Object
Returns the value of attribute base_url.
5 6 7 |
# File 'lib/canlii/configuration.rb', line 5 def base_url @base_url end |
#language ⇒ Object
Returns the value of attribute language.
5 6 7 |
# File 'lib/canlii/configuration.rb', line 5 def language @language end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/canlii/configuration.rb', line 5 def logger @logger end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/canlii/configuration.rb', line 5 def timeout @timeout end |
Instance Method Details
#validate! ⇒ Object
15 16 17 |
# File 'lib/canlii/configuration.rb', line 15 def validate! raise Error, "API key is required" if api_key.nil? || api_key.to_s.strip.empty? end |