Sha256: 5539497ff726fa9243015ee77bcdc5993e95a24149d1ad795582eed09d0b9c9b

Contents?: true

Size: 607 Bytes

Versions: 6

Compression:

Stored size: 607 Bytes

Contents

require "nokogiri"
require_relative "src/extractor"
require_relative "src/node"
require_relative "src/extract/value_builder"

class XmlDataExtractor   
  def initialize(config, modifiers = nil)
    @config = config
    @modifiers = modifiers
  end

  def parse(xml)
    extractor = Extractor.new(xml, config, modifiers)
    schemas = config.fetch(:schemas, {})

    {}.tap do |hash|
      schemas.map do |key, val|
        value = Extract::ValueBuilder.new(Node.new(val), extractor).value
        hash[key] = value if value.present?
      end
    end
  end

  private

  attr_reader :config, :modifiers
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xml_data_extractor-0.7.0 lib/xml_data_extractor.rb
xml_data_extractor-0.6.0 lib/xml_data_extractor.rb
xml_data_extractor-0.5.0 lib/xml_data_extractor.rb
xml_data_extractor-0.4.0 lib/xml_data_extractor.rb
xml_data_extractor-0.3.0 lib/xml_data_extractor.rb
xml_data_extractor-0.2.0 lib/xml_data_extractor.rb