Class: Nzbn::Configuration

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

Overview

Configuration class for NZBN client settings

Examples:

Production mode (default)

Nzbn.configure do |config|
  config.api_key = 'your-api-key'
end

Sandbox mode

Nzbn.configure do |config|
  config.api_key = 'your-api-key'
  config.mode = :sandbox
end

Custom base URL (overrides mode)

Nzbn.configure do |config|
  config.api_key = 'your-api-key'
  config.base_url = 'https://custom-url.example.com/nzbn/v5'
end

Constant Summary collapse

MODES =
%i[production sandbox].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



29
30
31
32
33
34
35
36
# File 'lib/nzbn/configuration.rb', line 29

def initialize
  @api_key = nil
  @mode = :production
  @base_url = Nzbn::PRODUCTION_BASE_URL
  @timeout = 30
  @open_timeout = 10
  @logger = nil
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



26
27
28
# File 'lib/nzbn/configuration.rb', line 26

def api_key
  @api_key
end

#base_urlObject

Returns the value of attribute base_url.



27
28
29
# File 'lib/nzbn/configuration.rb', line 27

def base_url
  @base_url
end

#loggerObject

Returns the value of attribute logger.



26
27
28
# File 'lib/nzbn/configuration.rb', line 26

def logger
  @logger
end

#modeObject

Returns the value of attribute mode.



27
28
29
# File 'lib/nzbn/configuration.rb', line 27

def mode
  @mode
end

#open_timeoutObject

Returns the value of attribute open_timeout.



26
27
28
# File 'lib/nzbn/configuration.rb', line 26

def open_timeout
  @open_timeout
end

#timeoutObject

Returns the value of attribute timeout.



26
27
28
# File 'lib/nzbn/configuration.rb', line 26

def timeout
  @timeout
end

Instance Method Details

#production?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/nzbn/configuration.rb', line 60

def production?
  @mode == :production
end

#sandbox?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/nzbn/configuration.rb', line 56

def sandbox?
  @mode == :sandbox
end

#valid?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/nzbn/configuration.rb', line 64

def valid?
  !api_key.nil? && !api_key.empty?
end