Class: Nmap::OSClass

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

Overview

Represents an OS class.

Instance Method Summary collapse

Methods included from CPE

#cpe, #each_cpe

Constructor Details

#initialize(node) ⇒ OSClass

Initializes the os class.

Parameters:

  • node (Nokogiri::XML::Node)

    The node that contains the OS Class information.



17
18
19
# File 'lib/nmap/os_class.rb', line 17

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.



67
68
69
# File 'lib/nmap/os_class.rb', line 67

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

#familySymbol?

The OS family.

Returns:

  • (Symbol, nil)


46
47
48
# File 'lib/nmap/os_class.rb', line 46

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

#genSymbol?

The OS generation.

Returns:

  • (Symbol, nil)


55
56
57
58
59
# File 'lib/nmap/os_class.rb', line 55

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.



77
78
79
# File 'lib/nmap/os_class.rb', line 77

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

#typeString

The OS type.

Returns:

  • (String)


26
27
28
29
30
# File 'lib/nmap/os_class.rb', line 26

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

#vendorString

The OS vendor.

Returns:

  • (String)


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

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