Class: IniFileReader

Inherits:
Reader show all
Defined in:
lib/teuton-get/reader/inifile_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(filepath = "") ⇒ IniFileReader

Returns a new instance of IniFileReader.



5
6
7
# File 'lib/teuton-get/reader/inifile_reader.rb', line 5

def initialize(filepath = "")
  @filepath = filepath
end

Instance Method Details

#read(filepath = :default) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/teuton-get/reader/inifile_reader.rb', line 13

def read(filepath = :default)
  @filepath = filepath unless filepath == :default
  return {} unless File.exist? @filepath

  inifile = IniFile.load(@filepath)
  data = {}
  inifile.sections.each do |section|
    data[section] = inifile[section]
  end
  data
end

#sourceObject



9
10
11
# File 'lib/teuton-get/reader/inifile_reader.rb', line 9

def source
  @filepath
end