Method: Puppet::Util::IniConfig::PhysicalFile#add_section

Defined in:
lib/puppet/util/inifile.rb

#add_section(name) ⇒ Puppet::Util::IniConfig::Section

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create a new section and store it in the file contents

Parameters:

  • name (String)

    The name of the section to create

Returns:



238
239
240
241
242
243
244
245
246
247
# File 'lib/puppet/util/inifile.rb', line 238

def add_section(name)
  if section_exists?(name)
    raise IniParseError.new(_("Section %{name} is already defined, cannot redefine") % { name: name.inspect }, @file)
  end

  section = Section.new(name, @file)
  @contents << section

  section
end