Class: Ronin::DB::Port
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Ronin::DB::Port
- Includes:
- Model
- Defined in:
- lib/ronin/db/port.rb
Overview
Represents a TCP or UDP port.
Instance Attribute Summary collapse
-
#id ⇒ Integer
The primary key of the port.
-
#number ⇒ Integer
The port number.
-
#open_ports ⇒ Array<OpenPort>
The open ports.
-
#protocol ⇒ :tcp, :udp
The protocol of the port (either
'tcp'
/'udp'
).
Class Method Summary collapse
-
.import(number) ⇒ Port
Creates a new Port.
-
.lookup(number) ⇒ Port?
Looks up a port by it's number.
Instance Method Summary collapse
-
#to_i ⇒ Integer
Converts the port to an integer.
-
#to_s ⇒ String
Converts the port to a string.
Methods included from Model
Instance Attribute Details
#id ⇒ Integer
The primary key of the port.
38 |
# File 'lib/ronin/db/port.rb', line 38 attribute :id, :integer |
#number ⇒ Integer
The port number.
51 |
# File 'lib/ronin/db/port.rb', line 51 attribute :number, :integer |
#open_ports ⇒ Array<OpenPort>
The open ports.
63 |
# File 'lib/ronin/db/port.rb', line 63 has_many :open_ports, dependent: :destroy |
#protocol ⇒ :tcp, :udp
The protocol of the port (either 'tcp'
/ 'udp'
).
44 |
# File 'lib/ronin/db/port.rb', line 44 enum :protocol, {tcp: 'tcp', udp: 'udp'}, default: :tcp |
Class Method Details
.import(number) ⇒ Port
Creates a new Port.
91 92 93 |
# File 'lib/ronin/db/port.rb', line 91 def self.import(number) create(number: number) end |
.lookup(number) ⇒ Port?
Looks up a port by it's number.
76 77 78 |
# File 'lib/ronin/db/port.rb', line 76 def self.lookup(number) find_by(number: number) end |
Instance Method Details
#to_i ⇒ Integer
Converts the port to an integer.
103 104 105 |
# File 'lib/ronin/db/port.rb', line 103 def to_i self.number.to_i end |
#to_s ⇒ String
Converts the port to a string.
115 116 117 |
# File 'lib/ronin/db/port.rb', line 115 def to_s "#{self.number}/#{self.protocol}" end |