Method: Ini#parse

Defined in:
lib/ini.rb

#parse(text) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/ini.rb', line 54

def parse(text)
  section = GLOBAL_SECTION
  text.each_line do |line|
    next if line.strip == ""
    next if line[0] == COMMENT_SYMBOL
    key, value = line.split(DELIMITER, 2).map(&:strip)
    if key && value
      @data[section][key] = cast(value)
      next
    end
    if /^\[(.+?)\]/ =~ line
      section = $1.strip
      @data[section] ||= {}
      next
    end
  end
end