Class: Ronin::Recon::Values::Host
- Inherits:
-
Ronin::Recon::Value
- Object
- Ronin::Recon::Value
- Ronin::Recon::Values::Host
- Defined in:
- lib/ronin/recon/values/host.rb
Overview
Represents a host-name (ex: www.example.com
).
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
The host name.
Class Method Summary collapse
-
.value_type ⇒ :host
private
Returns the type or kind of recon value.
Instance Method Summary collapse
-
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
-
#as_json ⇒ Hash{Symbol => Object}
Coerces the host value into JSON.
-
#eql?(other) ⇒ Boolean
Compares the value to another value.
-
#hash ⇒ Integer
The "hash" value of the host name.
-
#initialize(name) ⇒ Host
constructor
Initializes the host object.
-
#to_s ⇒ String
(also: #to_str)
Converts the IP object to a String.
Methods inherited from Ronin::Recon::Value
Constructor Details
#initialize(name) ⇒ Host
Initializes the host object.
48 49 50 |
# File 'lib/ronin/recon/values/host.rb', line 48 def initialize(name) @name = name end |
Instance Attribute Details
#name ⇒ String (readonly)
The host name.
40 41 42 |
# File 'lib/ronin/recon/values/host.rb', line 40 def name @name end |
Class Method Details
.value_type ⇒ :host
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.
This is used internally to map a recon value class to a printable type.
Returns the type or kind of recon value.
133 134 135 |
# File 'lib/ronin/recon/values/host.rb', line 133 def self.value_type :host end |
Instance Method Details
#===(other) ⇒ Boolean
Case equality method used for fuzzy matching.
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/ronin/recon/values/host.rb', line 77 def ===(other) case other when Host @name == other.name when IP, Website, URL @name == other.host when EmailAddress other.address.end_with?("@#{@name}") else false end end |
#as_json ⇒ Hash{Symbol => Object}
Coerces the host value into JSON.
118 119 120 |
# File 'lib/ronin/recon/values/host.rb', line 118 def as_json {type: :host, name: @name} end |
#eql?(other) ⇒ Boolean
Compares the value to another value.
62 63 64 |
# File 'lib/ronin/recon/values/host.rb', line 62 def eql?(other) self.class == other.class && @name == other.name end |
#hash ⇒ Integer
The "hash" value of the host name.
96 97 98 |
# File 'lib/ronin/recon/values/host.rb', line 96 def hash [self.class, @name].hash end |
#to_s ⇒ String Also known as: to_str
Converts the IP object to a String.
106 107 108 |
# File 'lib/ronin/recon/values/host.rb', line 106 def to_s @name.to_s end |