Class: Nmap::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/nmap/sequence.rb

Overview

Base class for all Sequence classes.

Since:

  • 0.5.0

Direct Known Subclasses

IpIdSequence, TcpSequence, TcpTsSequence

Instance Method Summary collapse

Constructor Details

#initialize(node) {|sequence| ... } ⇒ Sequence

Creates a new sequence object.

Parameters:

  • node (Nokogiri::XML::Node)

    The node that contains the sequence information.

Yields:

  • (sequence)

    If a block is given, it will passed the newly created sequence.

Yield Parameters:

  • sequence (Sequence)

    The newly created sequence object.

Since:

  • 0.5.0



23
24
25
26
27
# File 'lib/nmap/sequence.rb', line 23

def initialize(node)
  @node = node

  yield self if block_given?
end

Instance Method Details

#descriptionString

The description of the sequence.

Returns:

  • (String)

    The sequence class from nmap.

Since:

  • 0.5.0



37
38
39
# File 'lib/nmap/sequence.rb', line 37

def description
  @node['class']
end

#valuesArray<Numeric>

The values within the sequence.

Returns:

  • (Array<Numeric>)

    A sample of sequence numbers taken by nmap.

Since:

  • 0.5.0



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/nmap/sequence.rb', line 49

def values
  unless @values
    @values = []

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

  return @values
end