Class: GoFlippy::Config

Inherits:
Object
  • Object
show all
Includes:
Logger
Defined in:
lib/goflippy-ruby/config.rb

Constant Summary collapse

DEFAULT_API_URI =
'http://localhost'
DEFAULT_OPEN_TIMEOUT =
3
DEFAULT_READ_TIMEOUT =
10
DEFAULT_POLLING_INTERVAL =
300

Constants included from Logger

Logger::MESSAGE_PREFIX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Logger

debug, error, fatal, info, logger, logger=, unknown, warn

Constructor Details

#initialize(opts = {}) ⇒ Config

Returns a new instance of Config.



14
15
16
17
18
19
20
# File 'lib/goflippy-ruby/config.rb', line 14

def initialize(opts = {})
  @api_uri = (opts[:api_uri] || DEFAULT_API_URI).chomp('/')
  @open_timeout = (opts[:open_timeout] || DEFAULT_OPEN_TIMEOUT)
  @read_timeout = (opts[:read_timeout] || DEFAULT_READ_TIMEOUT)
  @polling_interval = (opts[:polling_interval] || DEFAULT_POLLING_INTERVAL)
  Logger.logger = opts[:logger] if opts[:logger]
end

Instance Attribute Details

#api_uriObject (readonly)

Returns the value of attribute api_uri.



9
10
11
# File 'lib/goflippy-ruby/config.rb', line 9

def api_uri
  @api_uri
end

#open_timeoutObject (readonly)

Returns the value of attribute open_timeout.



10
11
12
# File 'lib/goflippy-ruby/config.rb', line 10

def open_timeout
  @open_timeout
end

#polling_intervalObject (readonly)

Returns the value of attribute polling_interval.



12
13
14
# File 'lib/goflippy-ruby/config.rb', line 12

def polling_interval
  @polling_interval
end

#read_timeoutObject (readonly)

Returns the value of attribute read_timeout.



11
12
13
# File 'lib/goflippy-ruby/config.rb', line 11

def read_timeout
  @read_timeout
end

Class Method Details

.defaultObject



22
23
24
# File 'lib/goflippy-ruby/config.rb', line 22

def self.default
  Config.new
end