Class: Rockbox::Configuration

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

Overview

Mutable configuration holder used by the builder block API.

Examples:

client = Rockbox::Client.build do |c|
  c.host = "192.168.1.42"
  c.port = 6062
end

Constant Summary collapse

DEFAULT_HOST =
"localhost"
DEFAULT_PORT =
6062

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host: nil, port: nil, http_url: nil, ws_url: nil, open_timeout: nil, read_timeout: nil) ⇒ Configuration

Returns a new instance of Configuration.



17
18
19
20
21
22
23
24
25
# File 'lib/rockbox/configuration.rb', line 17

def initialize(host: nil, port: nil, http_url: nil, ws_url: nil,
               open_timeout: nil, read_timeout: nil)
  @host         = host
  @port         = port
  @http_url     = http_url
  @ws_url       = ws_url
  @open_timeout = open_timeout
  @read_timeout = read_timeout
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



15
16
17
# File 'lib/rockbox/configuration.rb', line 15

def host
  @host
end

#http_urlObject

Returns the value of attribute http_url.



15
16
17
# File 'lib/rockbox/configuration.rb', line 15

def http_url
  @http_url
end

#open_timeoutObject

Returns the value of attribute open_timeout.



15
16
17
# File 'lib/rockbox/configuration.rb', line 15

def open_timeout
  @open_timeout
end

#portObject

Returns the value of attribute port.



15
16
17
# File 'lib/rockbox/configuration.rb', line 15

def port
  @port
end

#read_timeoutObject

Returns the value of attribute read_timeout.



15
16
17
# File 'lib/rockbox/configuration.rb', line 15

def read_timeout
  @read_timeout
end

#ws_urlObject

Returns the value of attribute ws_url.



15
16
17
# File 'lib/rockbox/configuration.rb', line 15

def ws_url
  @ws_url
end

Instance Method Details

#resolved_hostObject



27
# File 'lib/rockbox/configuration.rb', line 27

def resolved_host;  @host  || DEFAULT_HOST end

#resolved_http_urlObject



30
31
32
# File 'lib/rockbox/configuration.rb', line 30

def resolved_http_url
  @http_url || "http://#{resolved_host}:#{resolved_port}/graphql"
end

#resolved_portObject



28
# File 'lib/rockbox/configuration.rb', line 28

def resolved_port;  @port  || DEFAULT_PORT end

#resolved_ws_urlObject



34
35
36
# File 'lib/rockbox/configuration.rb', line 34

def resolved_ws_url
  @ws_url || "ws://#{resolved_host}:#{resolved_port}/graphql"
end