Class: Avmtrf1::Ini

Inherits:
Object
  • Object
show all
Includes:
EacRubyUtils::SimpleCache
Defined in:
lib/avmtrf1/ini.rb,
lib/avmtrf1/ini/profile.rb

Overview

Leitor de arquivos .ini com suporte a herança de seções/perfis.

Defined Under Namespace

Classes: Profile

Constant Summary collapse

SECTION_NAME_PATTERN =
/\A([^\:]+)(?:\:([^\:]+))?\z/.freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(inifile) ⇒ Ini

Returns a new instance of Ini.

Parameters:

  • ini

    Um [IniFile] ou um caminho de arquivo .ini.



28
29
30
# File 'lib/avmtrf1/ini.rb', line 28

def initialize(inifile)
  @inifile = ::IniFile.load(inifile.to_s) unless inifile.is_a?(::IniFile)
end

Instance Attribute Details

#inifileObject (readonly)

Returns the value of attribute inifile.



25
26
27
# File 'lib/avmtrf1/ini.rb', line 25

def inifile
  @inifile
end

Class Method Details

.parse_section_name(section_name) ⇒ Object



17
18
19
20
21
22
# File 'lib/avmtrf1/ini.rb', line 17

def parse_section_name(section_name)
  m = SECTION_NAME_PATTERN.match(section_name)
  return [m[1], m[2]] if m

  raise "Section name pattern \"#{SECTION_NAME_PATTERN}\" not match \"#{section_name}\""
end