Sha256: cf7b8c909e3b4fbe854c23c4bc7e393a22b4063698ed74b2183bcaa2ea3138c8
Contents?: true
Size: 545 Bytes
Versions: 9
Compression:
Stored size: 545 Bytes
Contents
module Compactor module Amazon class XmlParser attr_reader :calculated_total, :expected_total def initialize(xml) calculate(Nokogiri::XML::Document.parse(xml)) end def valid? (expected_total.abs - calculated_total.abs).abs < 0.009 end private def calculate(doc) @expected_total = doc.xpath("//TotalAmount").text.to_f @calculated_total = 0.0 doc.xpath("//Amount").each { |t| @calculated_total += t.text.to_f } end end end end
Version data entries
9 entries across 9 versions & 1 rubygems