Sha256: 0278a03207517e5b20b4689bce0cf0e39ddaa55703085b54d89dd39aae3780af

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

module Nmap
  class Sequence

    #
    # Creates a new sequence object.
    #
    # @param [Nokogiri::XML::Node] node
    #   The node that contains the sequence information.
    #
    # @yield [sequence]
    #   If a block is given, it will passed the newly created sequence.
    #
    # @yieldparam [Sequence] sequence
    #   The newly created sequence object.
    #
    # @since 0.5.0
    #
    def initialize(node)
      @node = node

      yield self if block_given?
    end

    #
    # The description of the sequence.
    #
    # @return [String]
    #   The sequence class from nmap.
    # 
    # @since 0.5.0
    #
    def description
      @node['class']
    end

    #
    # The values within the sequence.
    #
    # @return [Array<Numeric>]
    #   A sample of sequence numbers taken by nmap.
    #
    # @since 0.5.0
    #
    def values
      unless @values
        @values = []

        if (string = @node['values'])
          string.scan(/[^\s,]+/) { |match| @values << match.to_i(16) }
        end
      end

      return @values
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ruby-nmap-0.5.1 lib/nmap/sequence.rb
ruby-nmap-0.5.0 lib/nmap/sequence.rb