Sha256: 76412f1f2098d81fad167b28383c230c5364d56c25d5ba7b2ce4dd9d530efda2
Contents?: true
Size: 992 Bytes
Versions: 10
Compression:
Stored size: 992 Bytes
Contents
module Puree module XMLExtractor # Base XML extractor. # class Base def initialize(xml) make_doc xml end # XPath search for a single value, at a given path. # # @return [String, nil] def xpath_query_for_single_value(path) xpath_result = xpath_query(path).text.strip xpath_result.empty? ? nil : xpath_result end # XPath search for multiple values, at a given path. # # @return [Array<String>] def xpath_query_for_multi_value(path) xpath_result = xpath_query path arr = [] xpath_result.each { |i| arr << i.text.strip } arr.uniq end private def setup_model(resource) resource_class = "Puree::Model::#{Puree::Util::String.titleize(resource)}" @model = Object.const_get(resource_class).new end def make_doc(xml) @doc = Nokogiri::XML xml @doc.remove_namespaces! end end end end
Version data entries
10 entries across 10 versions & 1 rubygems