Class Core::Config::XMLParser
In: core/config.rb
Parent: Object

ParserInterface implementation to read configuration parameters from a XML file.

Methods

get_option   get_type   new  

Included Modules

ParserInterface

Public Class methods

Returns :xml symbol. This method is used by the Factory to choose the appropiate implementation for a given file.

[Source]

    # File core/config.rb, line 52
52:       def XMLParser.get_type() return :xml; end

Read and parse the XML file. Stores the options in an internal Hash to speed up the retrieving process.

[Source]

    # File core/config.rb, line 56
56:       def initialize(file)
57:         src = REXML::Document.new(File.new(file))
58:         @options = {}
59:         src.elements.each('dradis/option') do |element|
60:           @options[element.attributes['name'].to_sym] = element.attributes['value']
61:         end
62:       end

Public Instance methods

See ParserInterface#get_option

[Source]

    # File core/config.rb, line 65
65:       def get_option(key)
66:         if @options.key?(key)
67:           @options[key]
68:         else
69:           raise ArgumentError.new('option not found in config file!')
70:         end
71:       end

[Validate]