Class: Ronin::Address

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/ronin/address.rb

Overview

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

Direct Known Subclasses

HostName, IPAddress, MACAddress

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Model

included

Class Method Details

.[](key) ⇒ Address?

Finds an address.

Parameters:

  • key (String, Integer)

    The address or index to search for.

Returns:

  • (Address, nil)

    The found address.

Since:

  • 1.0.0



90
91
92
93
94
95
96
# File 'lib/ronin/address.rb', line 90

def self.[](key)
  if key.kind_of?(String)
    first(:address => key)
  else
    super(key)
  end
end

.parse(address) ⇒ Address

Parses the address.

Parameters:

  • address (String)

    The address to parse.

Returns:

  • (Address)

    The parsed address.

Since:

  • 1.3.0



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

def self.parse(address)
  first_or_new(:address => address)
end

Instance Method Details

#inspectString

Inspects the address.

Returns:

  • (String)

    The inspected address.

Since:

  • 1.0.0



122
123
124
# File 'lib/ronin/address.rb', line 122

def inspect
  "#<#{self.class}: #{self.address}>"
end

#to_sString

Converts the address into a string.

Returns:

  • (String)

    The address.

Since:

  • 1.0.0



108
109
110
# File 'lib/ronin/address.rb', line 108

def to_s
  self.address.to_s
end