Class: CanLII::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/canlii/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/canlii/configuration.rb', line 5

def api_key
  @api_key
end

#base_urlObject

Returns the value of attribute base_url.



5
6
7
# File 'lib/canlii/configuration.rb', line 5

def base_url
  @base_url
end

#languageObject

Returns the value of attribute language.



5
6
7
# File 'lib/canlii/configuration.rb', line 5

def language
  @language
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/canlii/configuration.rb', line 5

def logger
  @logger
end

#timeoutObject

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

Raises:



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