Sha256: 17c6a7117e2e4e4cf5e4b7ac7b2efd12b2ef8ac73bf6c63fd7d7e6262273a154
Contents?: true
Size: 1.32 KB
Versions: 5
Compression:
Stored size: 1.32 KB
Contents
require 'nmap/hop' module Nmap # # Wraps the `trace` XML element. # # @since 0.7.0 # class Traceroute include Enumerable # # Creates a new traceroute. # # @param [Nokogiri::XML::Element] node # The `trace` XML element. # def initialize(node) @node = node end # # The port used for the traceroute. # # @return [Integer, nil] # The `port` XML attribute. # def port @port ||= if @node['port'] @node['port'].to_i end end # # The protocol used for the traceroute. # # @return [Symbol, nil] # The `proto` XML element. # def protocol @protocol ||= if @node['proto'] @node['proto'].to_sym end end # # Parses the traceroute information for the host. # # @yield [hop] # Each hop to the host. # # @yieldparam [Hop] hop # A hop to the host. # # @return [Traceroute, Enumerator] # The traceroute. # If no block was given, an enumerator will be returned. # def each return enum_for(__method__) unless block_given? @node.xpath('hop').each do |hop| yield Hop.new(hop['ipaddr'],hop['host'],hop['ttl'],hop['rtt']) end return self end end end
Version data entries
5 entries across 5 versions & 1 rubygems