Sha256: 794fa73e837fd040759eee8a305e7e8a1a62038f2e4426f0bac4c73191c13426
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
# frozen_string_literal: true require_relative 'hop' module Nmap class XML # # Wraps the `trace` XML element. # # @since 1.0.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 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ruby-nmap-1.0.3 | lib/nmap/xml/traceroute.rb |