lib/vnstat/document.rb in vnstat-ruby-3.0.5 vs lib/vnstat/document.rb in vnstat-ruby-3.0.6

- old
+ new

@@ -46,17 +46,23 @@ ## # Returns the version as specified in the vnstat element. # # @return [String] def version - data.xpath('vnstat').attr('version').text + attr = data.xpath('vnstat').attr('version') + raise 'Unable to determine version' if attr.nil? + + attr.text end ## # Returns the XML version as specified in the vnstat element. # # @return [String] def xml_version - data.xpath('vnstat').attr('xmlversion').text + attr = data.xpath('vnstat').attr('xmlversion') + raise 'Unable to determine XML version' if attr.nil? + + attr.text end end end