Class: Kentaa::Api::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/kentaa/api/config.rb

Constant Summary collapse

LIVE_URL =
'https://api.kentaa.nl/v1'
TEST_URL =
'https://api.kentaa.staatklaar.nu/v1'
DEV_URL =
'http://api.lvh.me:3000/v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Config

Returns a new instance of Config.



12
13
14
# File 'lib/kentaa/api/config.rb', line 12

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



10
11
12
# File 'lib/kentaa/api/config.rb', line 10

def options
  @options
end

Instance Method Details

#api_keyObject



16
17
18
# File 'lib/kentaa/api/config.rb', line 16

def api_key
  options.fetch(:api_key)
end

#api_urlObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/kentaa/api/config.rb', line 20

def api_url
  case environment
  when :test
    TEST_URL
  when :development
    DEV_URL
  when :live
    LIVE_URL
  end
end

#debug?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/kentaa/api/config.rb', line 41

def debug?
  options.fetch(:debug, false)
end

#environmentObject



31
32
33
34
35
36
37
38
39
# File 'lib/kentaa/api/config.rb', line 31

def environment
  if options[:test]
    :test
  elsif options[:dev]
    :development
  else
    :live
  end
end