class ARPScan::ScanReport

This class abstracts the string output from arp-scan into an Object. A ScanReports are usually created through the ScanResultProcessor module.

Attributes

arguments[R]

The argument string passed to ARPScan

hosts[R]

Array of Host objects.

interface[R]

Name of the interface used for the scan.

range_size[R]

Size of the scan range ( # of hosts scanned ).

reply_count[R]

The number of hosts that replied to the scan, returns a Fixnum

scan_rate[R]

The rate of the scan in hosts per second, returns a Float.

scan_time[R]

Duration of the scan in seconds, returns a Float.

version[R]

`arp-scan` version number.

Public Class Methods

new(hash) click to toggle source

Create a new scan report, passing in every attribute. The best way to do this is with the ScanResultProcessor module.

# File lib/arp_scan/scan_report.rb, line 45
def initialize(hash)
  @hosts = hash[:hosts]
  @interface = hash[:interface]
  @datalink = hash[:datalink]
  @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

Public Instance Methods

to_array() click to toggle source

Returns an array representation of the ScanReport. Metadata about the scan, and an array of Host arrays comprise the array.

# File lib/arp_scan/scan_report.rb, line 60
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() click to toggle source

Returns a hash representation of the ScanReport. Metadata about the scan, and array of Host hashes comprise the hash.

# File lib/arp_scan/scan_report.rb, line 73
def to_hash
  { hosts: @hosts.map(&:to_hash),
    interface: @interface,
    datalink: @datalink,
    version: @version,
    range_size: @range_size,
    scan_time: @scan_time,
    scan_rate: @scan_rate,
    reply_count: @reply_count,
    arguments: @arguments }
end