Class: Ronin::DB::MACAddress
- Defined in:
- lib/ronin/db/mac_address.rb
Overview
Represents MAC addresses and their associated IP addresses.
Instance Attribute Summary collapse
-
#address ⇒ String
The MAC address.
-
#ip_address_mac_addresses ⇒ Array<IPAddressMACAddress>
The IP Addresses the MAC Address hosts.
-
#ip_addresses ⇒ Array<IPAddress>
The IP Addresses associated with the MAC Address.
Attributes inherited from Address
Attributes included from Ronin::DB::Model::LastScannedAt
Instance Method Summary collapse
-
#recent_ip_address ⇒ IPAddress
The IP Address that most recently used the MAC Address.
-
#to_i ⇒ Integer
Converts the MAC address to an Integer.
Methods inherited from Address
Methods included from Ronin::DB::Model::LastScannedAt
Methods included from Ronin::DB::Model::Importable
Methods included from Model
Instance Attribute Details
#address ⇒ String
The MAC address.
37 |
# File 'lib/ronin/db/mac_address.rb', line 37 attribute :address, :string |
#ip_address_mac_addresses ⇒ Array<IPAddressMACAddress>
The IP Addresses the MAC Address hosts
50 51 |
# File 'lib/ronin/db/mac_address.rb', line 50 has_many :ip_address_mac_addresses, dependent: :destroy, class_name: 'IPAddressMACAddress' |
#ip_addresses ⇒ Array<IPAddress>
The IP Addresses associated with the MAC Address
57 58 |
# File 'lib/ronin/db/mac_address.rb', line 57 has_many :ip_addresses, through: :ip_address_mac_addresses, class_name: 'IPAddress' |
Instance Method Details
#recent_ip_address ⇒ IPAddress
The IP Address that most recently used the MAC Address.
68 69 70 |
# File 'lib/ronin/db/mac_address.rb', line 68 def recent_ip_address self.ip_address_mac_addresses.order('created_at DESC').ip_addresses.first end |
#to_i ⇒ Integer
Converts the MAC address to an Integer.
80 81 82 83 84 |
# File 'lib/ronin/db/mac_address.rb', line 80 def to_i self.address.split(':').reduce(0) do |bits,char| ((bits << 8) | char.hex) end end |