Class: Nobel::Config

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:

  • _self (Nobel::Config)

    the object that the method was called on



8
9
10
11
12
13
14
15
16
# File 'lib/nobel/config.rb', line 8

def initialize
  @api_host    = 'api.nobelprize.org'
  @api_version = 'v1'
  @json_parser = ->(d) { JSON.parse(d) }
  @http_client = Nobel::HTTP
  @debug       = false

  yield self if block_given?
end

Instance Attribute Details

#api_hostObject

Returns the value of attribute api_host.



5
6
7
# File 'lib/nobel/config.rb', line 5

def api_host
  @api_host
end

#api_versionObject

Returns the value of attribute api_version.



5
6
7
# File 'lib/nobel/config.rb', line 5

def api_version
  @api_version
end

#debugObject

Returns the value of attribute debug.



5
6
7
# File 'lib/nobel/config.rb', line 5

def debug
  @debug
end

#http_clientObject

Returns the value of attribute http_client.



5
6
7
# File 'lib/nobel/config.rb', line 5

def http_client
  @http_client
end

#json_parserObject

Returns the value of attribute json_parser.



5
6
7
# File 'lib/nobel/config.rb', line 5

def json_parser
  @json_parser
end

Instance Method Details

#base_urlObject



18
19
20
# File 'lib/nobel/config.rb', line 18

def base_url
  "http://#{api_host}/#{api_version}"
end

#debug?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/nobel/config.rb', line 22

def debug?
  debug
end