Class: Tenk::Configuration

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

Overview

Holds the configuration for a Tenk client (API key and base URL, and logger)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ Configuration

Intialize a Tenk::Configuration

Parameters:

  • opts (Hash) (defaults to: {})

    the configuration options



12
13
14
15
16
# File 'lib/configuration.rb', line 12

def initialize(opts = {})
  opts.each do |key, value|
    send("#{key}=", value)
  end
end

Instance Attribute Details

#api_baseString

Return the base URL of the API

Returns:

  • (String)

    the base URL of the API



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

def api_base
  @api_base || 'https://api.10000ft.com/api/v1'
end

#loggerLogger

Return the current logger being used by the gem

Returns:

  • (Logger)

    the current logger



26
27
28
29
30
31
32
33
# File 'lib/configuration.rb', line 26

def logger
  if @logger.blank?
    @logger = Logger.new(STDERR)
    @logger.level = Logger::WARN
  end

  @logger
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end