Class: IniReader

Inherits:
Object
  • Object
show all
Defined in:
lib/ini_reader.rb,
lib/inireader/base.rb,
lib/inireader/version.rb

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string = '') ⇒ IniReader

Returns a new instance of IniReader.



2
3
4
5
# File 'lib/inireader/base.rb', line 2

def initialize( string = '')
  @section_hash = {}
  parse(StringIO.new(string))
end

Class Method Details

.parse(filename) ⇒ Object



7
8
9
10
11
# File 'lib/inireader/base.rb', line 7

def self.parse(filename)
  reader = IniReader.new
  reader.send(:parse, File.open(filename, "r"))
  return reader
end

Instance Method Details

#[](section_name) ⇒ Object

returns the hash for a section of the inifile



14
15
16
# File 'lib/inireader/base.rb', line 14

def []( section_name )
  return @section_hash[section_name]
end