Class: Ronin::DB::Address

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
Model, Model::Importable, Model::LastScannedAt
Defined in:
lib/ronin/db/address.rb

Overview

A base model which represents an Internet Address, such as:

Direct Known Subclasses

IPAddress, MACAddress

Instance Attribute Summary collapse

Attributes included from Model::LastScannedAt

#last_scanned_at

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model::LastScannedAt

included

Methods included from Model::Importable

included

Methods included from Model

included

Instance Attribute Details

#addressString

The Address

Returns:

  • (String)


54
# File 'lib/ronin/db/address.rb', line 54

attribute :address, :string

#created_atTime

Tracks when the IP Address was first created

Returns:

  • (Time)


61
# File 'lib/ronin/db/address.rb', line 61

attribute :created_at, :datetime

#idInteger

The primary key of the Address

Returns:

  • (Integer)


48
# File 'lib/ronin/db/address.rb', line 48

attribute :id, :integer

Class Method Details

.import(address) ⇒ Address

Imports an address.

Parameters:

  • address (String)

    The address to parse.

Returns:

  • (Address)

    The imported address.



89
90
91
# File 'lib/ronin/db/address.rb', line 89

def self.import(address)
  create(address: address)
end

.lookup(address) ⇒ Address?

Looks up the address.

Parameters:

  • address (String)

    The address to query.

Returns:

  • (Address, nil)

    The found address.



74
75
76
# File 'lib/ronin/db/address.rb', line 74

def self.lookup(address)
  find_by(address: address)
end

Instance Method Details

#to_sString

Converts the address into a string.

Returns:

  • (String)

    The address.



101
102
103
# File 'lib/ronin/db/address.rb', line 101

def to_s
  self.address.to_s
end