Class: Ronin::Recon::Values::IP

Inherits:
Ronin::Recon::Value show all
Defined in:
lib/ronin/recon/values/ip.rb

Overview

Represents an IP address.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Ronin::Recon::Value

#==, parse, #to_csv, #to_json

Constructor Details

#initialize(address, host: nil) ⇒ IP

Initializes the IP object.

Parameters:

  • address (String)

    The IP address.

  • host (String, nil) (defaults to: nil)

    The host name for the IP address.



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

#addressString (readonly)

The IP address.

Returns:

  • (String)


36
37
38
# File 'lib/ronin/recon/values/ip.rb', line 36

def address
  @address
end

#hostString? (readonly)

The optional parent host name.

Returns:

  • (String, nil)


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.

Returns:

  • (:ip)


116
117
118
# File 'lib/ronin/recon/values/ip.rb', line 116

def self.value_type
  :ip
end

Instance Method Details

#as_jsonHash{Symbol => Object}

Coerces the IP value into JSON.

Returns:

  • (Hash{Symbol => Object})

    The Ruby Hash that will be converted 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.

Parameters:

  • other (Value)

    The other value to compare.

Returns:



67
68
69
# File 'lib/ronin/recon/values/ip.rb', line 67

def eql?(other)
  other.kind_of?(self.class) && @address == other.address
end

#hashInteger

The "hash" value for the IP address.

Returns:

  • (Integer)

    The hash of the #address.



79
80
81
# File 'lib/ronin/recon/values/ip.rb', line 79

def hash
  [self.class, @address].hash
end

#to_sString Also known as: to_str

Converts the IP object to a String.

Returns:

  • (String)

    The IP address.



89
90
91
# File 'lib/ronin/recon/values/ip.rb', line 89

def to_s
  @address.to_s
end