Sha256: 969a083b38e1292e356e30eeab0a1782cecb0e0a86f44baa70ae40121be35389
Contents?: true
Size: 774 Bytes
Versions: 8
Compression:
Stored size: 774 Bytes
Contents
require "reactor/tools/response_handler/xml_attribute" require "reactor/tools/xpath_extractor" require "rexml/document" module Reactor module Cm class XmlResponse attr_reader :xml, :xml_str def initialize(xml) @xml_str = xml @xml = REXML::Document.new(xml) @handler = Reactor::ResponseHandler::XmlAttribute.new @xpath = Reactor::XPathExtractor.new(@xml) end def xpath(expr) @xpath.match(expr) end def ok? xp = xpath("//cm-code") if xp.is_a?(Array) codes = xp.map { |result| result.attribute("numeric").value }.uniq return codes.size == 1 && codes.first == "200" end xp.attribute("numeric").value == "200" end end end end
Version data entries
8 entries across 8 versions & 1 rubygems