class Ronin::Support::Network::ASN::Record

Represents an individual ASN record.

Attributes

country_code[R]

The country code of the ASN record.

@return [String, nil]

name[R]

The name of the ASN record.

@return [String, nil]

number[R]

The ASN number.

@return [Integer]

range[R]

The IP range of the ASN record.

@return [IPRange::CIDR, IPRange::Range]

to_i[R]

The ASN number.

@return [Integer]

Public Class Methods

new(number,range,country_code,name) click to toggle source

Initializes the record.

@param [Integer] number

The ASN number.

@param [IPRange::CIDR, IPRange::Range] range

The IP range of the ASN record.

@param [String, nil] country_code

The country code of the ASN record.

@param [String] name

The name of the ASN record.
# File lib/ronin/support/network/asn/record.rb, line 63
def initialize(number,range,country_code,name)
  @number       = number
  @range        = range
  @country_code = country_code
  @name         = name
end

Public Instance Methods

==(other) click to toggle source

Compares the record to another object.

@param [Object] other

The other object to compare to.

@return [Boolean]

# File lib/ronin/support/network/asn/record.rb, line 140
def ==(other)
  self.class == other.class &&
    @number       == other.number &&
    @range        == other.range &&
    @country_code == other.country_code &&
    @name         == other.name
end
each(&block) click to toggle source

Enumerates over every IP within the ASN range.

@yield [ip]

@yieldparam [IP] ip

@return [Enumerator]

# File lib/ronin/support/network/asn/record.rb, line 128
def each(&block)
  @range.each(&block)
end
include?(ip) click to toggle source

Determines if the IP belongs to the ASN range.

@param [IPAddr, String] ip

@return [Boolean]

# File lib/ronin/support/network/asn/record.rb, line 115
def include?(ip)
  @range.include?(ip)
end
ipv4?() click to toggle source

Determines if the ASN record has an IPv4 IP range.

@return [Boolean]

# File lib/ronin/support/network/asn/record.rb, line 95
def ipv4?
  @range.ipv4?
end
ipv6?() click to toggle source

Determines if the ASN record has an IPv6 IP range.

@return [Boolean]

# File lib/ronin/support/network/asn/record.rb, line 104
def ipv6?
  @range.ipv6?
end
not_routed?() click to toggle source

Determines if the ASN is not routed.

@return [Boolean]

# File lib/ronin/support/network/asn/record.rb, line 86
def not_routed?
  @number == 0
end
routed?() click to toggle source

Determines if the ASN is routed.

@return [Boolean]

# File lib/ronin/support/network/asn/record.rb, line 77
def routed?
  @number != 0
end
to_s() click to toggle source

Converts the record into a humanly readable String.

@return [String]

The String including the {#range}, {#number}, {#country_code},
and {#name}.
# File lib/ronin/support/network/asn/record.rb, line 155
def to_s
  if routed?
    "#{range} AS#{number} (#{country_code}) #{name}"
  else
    "#{range} Not routed"
  end
end