Class: VpsbClient::Config
- Inherits:
-
Object
- Object
- VpsbClient::Config
- Defined in:
- lib/vpsb_client/config.rb
Instance Method Summary collapse
- #[](name) ⇒ Object
- #fetch(name, default = nil) ⇒ Object
-
#initialize(path) ⇒ Config
constructor
A new instance of Config.
Constructor Details
#initialize(path) ⇒ Config
Returns a new instance of Config.
5 6 7 8 |
# File 'lib/vpsb_client/config.rb', line 5 def initialize(path) raise ArgumentError, "Can't find #{path}" unless File.exist?(path) @yml = YAML.load_file(path) end |
Instance Method Details
#[](name) ⇒ Object
14 15 16 |
# File 'lib/vpsb_client/config.rb', line 14 def [](name) fetch(name.to_s) end |
#fetch(name, default = nil) ⇒ Object
10 11 12 |
# File 'lib/vpsb_client/config.rb', line 10 def fetch(name, default=nil) default ? @yml.fetch(name.to_s, default) : @yml.fetch(name.to_s) end |