Class: Confuse::Source::Ini

Inherits:
Object
  • Object
show all
Defined in:
lib/confuse/source/ini.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Ini

Returns a new instance of Ini.



8
9
10
# File 'lib/confuse/source/ini.rb', line 8

def initialize(options = {})
  @ini = from_file(options[:path])
end

Instance Method Details

#[](namespace, key) ⇒ Object



18
19
20
21
# File 'lib/confuse/source/ini.rb', line 18

def [](namespace, key)
  namespace ||= :global
  @ini[namespace.to_s][key.to_s]
end

#from_file(file) ⇒ Object



12
13
14
15
16
# File 'lib/confuse/source/ini.rb', line 12

def from_file(file)
  IniFile.load(file).to_h
rescue IniFile::Error
  nil
end