Class: Ronin::Recon::Values::IP
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::IP
- Defined in:
- lib/ronin/recon/values/ip.rb
Overview
Represents an IP address.
Instance Attribute Summary collapse
-
#address ⇒ String
readonly
The IP address.
-
#host ⇒ String?
readonly
The optional parent host name.
Class Method Summary collapse
-
.value_type ⇒ :ip
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the IP value into JSON.
-
#eql?(other) ⇒ Boolean
(also: #===)
Compares the value to another value.
-
#hash ⇒ Integer
The "hash" value for the IP address.
-
#initialize(address, host: nil) ⇒ IP
constructor
Initializes the IP object.
-
#to_s ⇒ String
(also: #to_str)
Converts the IP object to a String.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(address, host: nil) ⇒ IP
Initializes the IP object.
52 53 54 55 |
# File 'lib/ronin/recon/values/ip.rb', line 52 def initialize(address, host: nil) @address = address @host = host end |
Instance Attribute Details
#address ⇒ String (readonly)
The IP address.
36 37 38 |
# File 'lib/ronin/recon/values/ip.rb', line 36 def address @address end |
#host ⇒ String? (readonly)
The optional parent host name.
41 42 43 |
# File 'lib/ronin/recon/values/ip.rb', line 41 def host @host end |
Class Method Details
.value_type ⇒ :ip
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Note:
This is used internally to map a recon value class to a printable type.
Returns the type or kind of recon value.
116 117 118 |
# File 'lib/ronin/recon/values/ip.rb', line 116 def self.value_type :ip end |
Instance Method Details
#as_json ⇒ Hash{Symbol => Object}
Coerces the IP value into JSON.
101 102 103 |
# File 'lib/ronin/recon/values/ip.rb', line 101 def as_json {type: :ip, address: @address} end |
#eql?(other) ⇒ Boolean Also known as: ===
Compares the value to another value.
67 68 69 |
# File 'lib/ronin/recon/values/ip.rb', line 67 def eql?(other) other.kind_of?(self.class) && @address == other.address end |
#hash ⇒ Integer
The "hash" value for the IP address.
79 80 81 |
# File 'lib/ronin/recon/values/ip.rb', line 79 def hash [self.class, @address].hash end |
#to_s ⇒ String Also known as: to_str
Converts the IP object to a String.
89 90 91 |
# File 'lib/ronin/recon/values/ip.rb', line 89 def to_s @address.to_s end |