Class: Nmap::XML::OSClass

Inherits:
Object
  • Object
show all
Includes:
CPE
Defined in:
lib/nmap/xml/os_class.rb

Overview

Represents an OS class.

Since:

  • 1.0.0

Instance Method Summary collapse

Methods included from CPE

#cpe, #each_cpe

Constructor Details

#initialize(node) ⇒ OSClass

Initializes the OS.

Parameters:

  • node (Nokogiri::XML::Node)

    The node that contains the OS Class information.

Since:

  • 1.0.0



22
23
24
# File 'lib/nmap/xml/os_class.rb', line 22

def initialize(node)
  @node = node
end

Instance Method Details

#accuracyInteger

The accuracy of the OS class information.

Returns:

  • (Integer)

    Returns a number between 0 and 10.

Since:

  • 1.0.0



72
73
74
# File 'lib/nmap/xml/os_class.rb', line 72

def accuracy
  @accuracy ||= @node.get_attribute('accuracy').to_i
end

#familySymbol?

The OS family.

Returns:

  • (Symbol, nil)

Since:

  • 1.0.0



51
52
53
# File 'lib/nmap/xml/os_class.rb', line 51

def family
  @family ||= @node.get_attribute('osfamily').to_sym
end

#genSymbol?

The OS generation.

Returns:

  • (Symbol, nil)

Since:

  • 1.0.0



60
61
62
63
64
# File 'lib/nmap/xml/os_class.rb', line 60

def gen
  @gen ||= if @node['osgen']
             @node['osgen'].to_sym
           end
end

#to_sString

Converts the OS class to a String.

Returns:

  • (String)

    The String form of the OS class.

Since:

  • 1.0.0



82
83
84
# File 'lib/nmap/xml/os_class.rb', line 82

def to_s
  "#{self.type} #{self.vendor} (#{self.accuracy}%)"
end

#typeString

The OS type.

Returns:

  • (String)

Since:

  • 1.0.0



31
32
33
34
35
# File 'lib/nmap/xml/os_class.rb', line 31

def type
  @type ||= if @node['type']
              @node['type'].to_sym
            end
end

#vendorString

The OS vendor.

Returns:

  • (String)

Since:

  • 1.0.0



42
43
44
# File 'lib/nmap/xml/os_class.rb', line 42

def vendor
  @vendor ||= @node.get_attribute('vendor')
end