lib/nmap/xml.rb in ruby-nmap-0.5.1 vs lib/nmap/xml.rb in ruby-nmap-0.6.0

- old
+ new

@@ -4,10 +4,13 @@ require 'nmap/host' require 'nokogiri' module Nmap + # + # Represents an Nmap XML file. + # class XML include Enumerable # Path of the Nmap XML scan file @@ -25,11 +28,11 @@ # @yieldparam [XML] xml # The newly created XML object. # def initialize(path) @path = File.expand_path(path) - @doc = Nokogiri::XML(File.new(@path)) + @doc = Nokogiri::XML(open(@path)) yield self if block_given? end # @@ -132,11 +135,11 @@ # @return [XML, Enumerator] # The XML object. If no block was given, an enumerator object will # be returned. # def each_host(&block) - return enum_for(:each_host) unless block + return enum_for(__method__) unless block @doc.xpath('/nmaprun/host').each do |host| Host.new(host,&block) end @@ -165,10 +168,10 @@ # @return [XML, Enumerator] # The XML parser. If no block was given, an enumerator object will # be returned. # def each_up_host(&block) - return enum_for(:each_up_host) unless block + return enum_for(__method__) unless block @doc.xpath("/nmaprun/host[status[@state='up']]").each do |host| Host.new(host,&block) end