Class: ARPScan::ScanReport
- Inherits:
-
Object
- Object
- ARPScan::ScanReport
- Defined in:
- lib/arp_scan/scan_report.rb
Overview
This class abstracts the string output from arp-scan into an Object. A ScanReports are usually created through the ScanResultProcessor module.
Instance Attribute Summary collapse
-
#arguments ⇒ Object
readonly
The argument string passed to ARPScan.
-
#datalink ⇒ Object
readonly
Information about the interface type.
-
#hosts ⇒ Object
readonly
Array of Host objects.
-
#interface ⇒ Object
readonly
Name of the interface used for the scan.
-
#ipv4 ⇒ Object
readonly
IP address of interface.
-
#mac ⇒ Object
readonly
MAC address of the interface.
-
#range_size ⇒ Object
readonly
Size of the scan range ( # of hosts scanned ).
-
#reply_count ⇒ Object
readonly
The number of hosts that replied to the scan, returns a Fixnum.
-
#scan_rate ⇒ Object
readonly
The rate of the scan in hosts per second, returns a Float.
-
#scan_time ⇒ Object
readonly
Duration of the scan in seconds, returns a Float.
-
#version ⇒ Object
readonly
‘arp-scan` version number.
Instance Method Summary collapse
-
#initialize(hash) ⇒ ScanReport
constructor
Create a new scan report, passing in every attribute.
-
#to_array ⇒ Object
Returns an array representation of the ScanReport.
-
#to_hash ⇒ Object
Returns a hash representation of the ScanReport.
Constructor Details
#initialize(hash) ⇒ ScanReport
Create a new scan report, passing in every attribute. The best way to do this is with the ScanResultProcessor module.
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/arp_scan/scan_report.rb', line 53 def initialize(hash) @hosts = hash[:hosts] @interface = hash[:interface] @datalink = hash[:datalink] @ipv4 = hash[:ipv4] @mac = hash[:mac] @version = hash[:version] @range_size = Integer(hash[:range_size]) @scan_time = Float(hash[:scan_time]) @scan_rate = Float(hash[:scan_rate]) @reply_count = Integer(hash[:reply_count]) @arguments = hash[:arguments] end |
Instance Attribute Details
#arguments ⇒ Object (readonly)
The argument string passed to ARPScan
48 49 50 |
# File 'lib/arp_scan/scan_report.rb', line 48 def arguments @arguments end |
#datalink ⇒ Object (readonly)
Information about the interface type.
18 19 20 |
# File 'lib/arp_scan/scan_report.rb', line 18 def datalink @datalink end |
#hosts ⇒ Object (readonly)
Array of Host objects.
10 11 12 |
# File 'lib/arp_scan/scan_report.rb', line 10 def hosts @hosts end |
#interface ⇒ Object (readonly)
Name of the interface used for the scan.
14 15 16 |
# File 'lib/arp_scan/scan_report.rb', line 14 def interface @interface end |
#ipv4 ⇒ Object (readonly)
IP address of interface
22 23 24 |
# File 'lib/arp_scan/scan_report.rb', line 22 def ipv4 @ipv4 end |
#mac ⇒ Object (readonly)
MAC address of the interface
26 27 28 |
# File 'lib/arp_scan/scan_report.rb', line 26 def mac @mac end |
#range_size ⇒ Object (readonly)
Size of the scan range ( # of hosts scanned ).
34 35 36 |
# File 'lib/arp_scan/scan_report.rb', line 34 def range_size @range_size end |
#reply_count ⇒ Object (readonly)
The number of hosts that replied to the scan, returns a Fixnum
45 46 47 |
# File 'lib/arp_scan/scan_report.rb', line 45 def reply_count @reply_count end |
#scan_rate ⇒ Object (readonly)
The rate of the scan in hosts per second, returns a Float.
42 43 44 |
# File 'lib/arp_scan/scan_report.rb', line 42 def scan_rate @scan_rate end |
#scan_time ⇒ Object (readonly)
Duration of the scan in seconds, returns a Float.
38 39 40 |
# File 'lib/arp_scan/scan_report.rb', line 38 def scan_time @scan_time end |
#version ⇒ Object (readonly)
‘arp-scan` version number.
30 31 32 |
# File 'lib/arp_scan/scan_report.rb', line 30 def version @version end |
Instance Method Details
#to_array ⇒ Object
Returns an array representation of the ScanReport. Metadata about the scan, and an array of Host arrays comprise the array.
70 71 72 73 74 75 76 77 78 |
# File 'lib/arp_scan/scan_report.rb', line 70 def to_array instance_variables.map do |var| if var == :@hosts instance_variable_get(var).map(&:to_array) else instance_variable_get(var) end end end |
#to_hash ⇒ Object
Returns a hash representation of the ScanReport. Metadata about the scan, and array of Host hashes comprise the hash.
83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/arp_scan/scan_report.rb', line 83 def to_hash { hosts: @hosts.map(&:to_hash), interface: @interface, datalink: @datalink, ipv4: @ipv4, mac: @mac, version: @version, range_size: @range_size, scan_time: @scan_time, scan_rate: @scan_rate, reply_count: @reply_count, arguments: @arguments } end |