Class: VpsbClient::Config

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Config

Returns a new instance of Config.

Raises:

  • (ArgumentError)


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