Class: Urbit::Config

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

Overview

Injected into a Ship to provide configuration

Constant Summary collapse

DEFAULT_CODE =
'lidlut-tabwed-pillex-ridrup'.freeze
DEFAULT_CONFIG_FILE =
'_config.yml'.freeze
DEFAULT_HOST =
'http://localhost'.freeze
DEFAULT_PORT =
'8080'.freeze
DEFAULT_NAME =
'~zod'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code: nil, config_file: nil, host: nil, name: nil, port: nil) ⇒ Config

Returns a new instance of Config.



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

def initialize(code: nil,  config_file: nil, host: nil, name: nil, port: nil)
  @config_file = config_file || DEFAULT_CONFIG_FILE
  @code = code || loaded_config['code'] || DEFAULT_CODE
  @host = host || loaded_config['host'] || DEFAULT_HOST
  @name = name || loaded_config['ship'] || DEFAULT_NAME
  @port = port || loaded_config['port'] || DEFAULT_PORT
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



6
7
8
# File 'lib/urbit/config.rb', line 6

def code
  @code
end

#config_fileObject (readonly)

Returns the value of attribute config_file.



6
7
8
# File 'lib/urbit/config.rb', line 6

def config_file
  @config_file
end

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/urbit/config.rb', line 6

def host
  @host
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/urbit/config.rb', line 6

def name
  @name
end

#portObject (readonly)

Returns the value of attribute port.



6
7
8
# File 'lib/urbit/config.rb', line 6

def port
  @port
end

Instance Method Details

#api_base_urlObject



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

def api_base_url
  @api_base_url ||= "#{host}:#{port}"
end