Class: Urbit::Config
- Inherits:
-
Object
- Object
- Urbit::Config
- 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
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
- #api_base_url ⇒ Object
-
#initialize(code: nil, config_file: nil, host: nil, name: nil, port: nil) ⇒ Config
constructor
A new instance of Config.
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
6 7 8 |
# File 'lib/urbit/config.rb', line 6 def code @code end |
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
6 7 8 |
# File 'lib/urbit/config.rb', line 6 def config_file @config_file end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
6 7 8 |
# File 'lib/urbit/config.rb', line 6 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/urbit/config.rb', line 6 def name @name end |
#port ⇒ Object (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_url ⇒ Object
22 23 24 |
# File 'lib/urbit/config.rb', line 22 def api_base_url @api_base_url ||= "#{host}:#{port}" end |