Class: VagrantPlugins::ProxyConf::Config::Key
- Inherits:
-
Object
- Object
- VagrantPlugins::ProxyConf::Config::Key
- Defined in:
- lib/vagrant-proxyconf/config/key.rb
Overview
Configuration key specifications
Instance Attribute Summary collapse
-
#default ⇒ String?
readonly
The default value for the key.
-
#env_var ⇒ String?
readonly
The environment variable name.
-
#name ⇒ Symbol
readonly
The configuration key name.
Instance Method Summary collapse
-
#initialize(name, opts = {}) ⇒ Key
constructor
A new instance of Key.
-
#value_from_env_var {|default| ... } ⇒ String
The value from the environment variable or the return value of the block or #default.
Constructor Details
#initialize(name, opts = {}) ⇒ Key
Returns a new instance of Key.
20 21 22 23 24 |
# File 'lib/vagrant-proxyconf/config/key.rb', line 20 def initialize(name, opts = {}) @name = name.to_sym @default = opts[:default] @env_var = opts[:env_var] end |
Instance Attribute Details
#default ⇒ String? (readonly)
Returns the default value for the key.
10 11 12 |
# File 'lib/vagrant-proxyconf/config/key.rb', line 10 def default @default end |
#env_var ⇒ String? (readonly)
Returns the environment variable name.
13 14 15 |
# File 'lib/vagrant-proxyconf/config/key.rb', line 13 def env_var @env_var end |
#name ⇒ Symbol (readonly)
Returns the configuration key name.
7 8 9 |
# File 'lib/vagrant-proxyconf/config/key.rb', line 7 def name @name end |
Instance Method Details
#value_from_env_var {|default| ... } ⇒ String
The value from the environment variable or the return value of the block or #default
31 32 33 34 35 36 37 38 39 |
# File 'lib/vagrant-proxyconf/config/key.rb', line 31 def value_from_env_var if env_var && ENV.key?(env_var) ENV[env_var] elsif block_given? yield default else default end end |