Module: Barometer::Utils::XmlReader

Defined in:
lib/barometer/utils/xml_reader.rb

Class Method Summary collapse

Class Method Details

.parse(xml, *nodes_to_remove) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/barometer/utils/xml_reader.rb', line 8

def self.parse(xml, *nodes_to_remove)
  xml_reader = Nori.new(
    parser: :nokogiri,
    strip_namespaces: true
  )
  output = xml_reader.parse(xml)

  nodes_to_remove.each do |node|
    output = output.fetch(node, output)
  end

  if block_given? && output
    output = yield(output)
  end

  output
end