class MWS::Orders::Document
Wraps a Nokogiri node
Attributes
node[R]
Public Class Methods
new(node)
click to toggle source
# File lib/mws/orders/document.rb, line 9 def initialize(node) @node = node end
Public Instance Methods
at_xpath(path)
click to toggle source
# File lib/mws/orders/document.rb, line 17 def at_xpath(path) node.at_xpath(add_namespace(path), namespaces) end
xpath(path)
click to toggle source
# File lib/mws/orders/document.rb, line 13 def xpath(path) node.xpath(add_namespace(path), namespaces) end
Private Instance Methods
add_namespace(path)
click to toggle source
# File lib/mws/orders/document.rb, line 23 def add_namespace(path) path.split('/') .map { |attr| attr.include?(':') ? attr : "xmlns:#{attr}" } .join('/') end
collect_namespaces()
click to toggle source
# File lib/mws/orders/document.rb, line 33 def collect_namespaces document = node&.document || node document.collect_namespaces.each_with_object({}) do |namespace, hsh| key, val = namespace hsh[key.sub(/^xmlns:/, '')] = val end end
namespaces()
click to toggle source
# File lib/mws/orders/document.rb, line 29 def namespaces @namespaces ||= collect_namespaces end