Skip to content

Commit

Permalink
Added OSMatch#os_class.
Browse files Browse the repository at this point in the history
  • Loading branch information
postmodern committed Jan 25, 2024
1 parent bd22d69 commit 1102182
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/nmap/xml/os_match.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

require_relative 'os_class'

module Nmap
class XML
#
Expand Down Expand Up @@ -39,6 +41,17 @@ def accuracy
@accuracy ||= @node['accuracy'].to_i
end

#
# The OS matches OS class.
#
# @return [OSClass]
#
# @since 1.1.0
#
def os_class
@os_class ||= OSClass.new(@node.at_xpath('osclass'))
end

#
# Converts the OS match to a String.
#
Expand Down
6 changes: 6 additions & 0 deletions spec/xml/os_match_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
end
end

describe "#os_class" do
it "must return a Nmap::XML::OSClass object" do
expect(subject.os_class).to be_kind_of(Nmap::XML::OSClass)
end
end

describe "#to_s" do
it "should include the name and accuracy" do
expect(subject.to_s).to eq("#{name} (#{accuracy}%)")
Expand Down

0 comments on commit 1102182

Please sign in to comment.