class IniParse::SectionCollection

A implementation of LineCollection used for storing (mostly) Option instances contained within a Section.

Since it is assumed that an INI document will only represent a section once, if SectionCollection encounters a Section key already held in the collection, the existing section is merged with the new one (see IniParse::Lines::Section#merge!).

Public Instance Methods

<<(line) click to toggle source
Calls superclass method IniParse::LineCollection#<<
# File lib/iniparse/line_collection.rb, line 113
def <<(line)
  if line.kind_of?(IniParse::Lines::Option)
    option = line
    line   = IniParse::Lines::AnonymousSection.new

    line.lines << option if option
  end

  if line.blank? || (! has_key?(line.key))
    super # Adding a new section, comment or blank line.
  else
    self[line.key].merge!(line)
  end

  self
end