Class: Ronin::Support::Network::ASN::Record
- Inherits:
-
Object
- Object
- Ronin::Support::Network::ASN::Record
- Defined in:
- lib/ronin/support/network/asn/record.rb
Overview
Represents an individual ASN record.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#country_code ⇒ String?
readonly
The country code of the ASN record.
-
#name ⇒ String?
readonly
The name of the ASN record.
-
#number ⇒ Integer
(also: #to_i)
readonly
The ASN number.
-
#range ⇒ IPRange::CIDR, IPRange::Range
readonly
The IP range of the ASN record.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Compares the record to another object.
-
#each {|ip| ... } ⇒ Enumerator
Enumerates over every IP within the ASN range.
-
#include?(ip) ⇒ Boolean
Determines if the IP belongs to the ASN range.
-
#initialize(number, range, country_code, name) ⇒ Record
constructor
Initializes the record.
-
#ipv4? ⇒ Boolean
Determines if the ASN record has an IPv4 IP range.
-
#ipv6? ⇒ Boolean
Determines if the ASN record has an IPv6 IP range.
-
#not_routed? ⇒ Boolean
Determines if the ASN is not routed.
-
#routed? ⇒ Boolean
Determines if the ASN is routed.
-
#to_s ⇒ String
Converts the record into a humanly readable String.
Constructor Details
#initialize(number, range, country_code, name) ⇒ Record
Initializes the record.
63 64 65 66 67 68 |
# 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 |
Instance Attribute Details
#country_code ⇒ String? (readonly)
The country code of the ASN record.
41 42 43 |
# File 'lib/ronin/support/network/asn/record.rb', line 41 def country_code @country_code end |
#name ⇒ String? (readonly)
The name of the ASN record.
46 47 48 |
# File 'lib/ronin/support/network/asn/record.rb', line 46 def name @name end |
#number ⇒ Integer (readonly) Also known as: to_i
The ASN number.
31 32 33 |
# File 'lib/ronin/support/network/asn/record.rb', line 31 def number @number end |
#range ⇒ IPRange::CIDR, IPRange::Range (readonly)
The IP range of the ASN record.
36 37 38 |
# File 'lib/ronin/support/network/asn/record.rb', line 36 def range @range end |
Instance Method Details
#==(other) ⇒ Boolean
Compares the record to another object.
140 141 142 143 144 145 146 |
# 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 {|ip| ... } ⇒ Enumerator
Enumerates over every IP within the ASN range.
128 129 130 |
# File 'lib/ronin/support/network/asn/record.rb', line 128 def each(&block) @range.each(&block) end |
#include?(ip) ⇒ Boolean
Determines if the IP belongs to the ASN range.
115 116 117 |
# File 'lib/ronin/support/network/asn/record.rb', line 115 def include?(ip) @range.include?(ip) end |
#ipv4? ⇒ Boolean
Determines if the ASN record has an IPv4 IP range.
95 96 97 |
# File 'lib/ronin/support/network/asn/record.rb', line 95 def ipv4? @range.ipv4? end |
#ipv6? ⇒ Boolean
Determines if the ASN record has an IPv6 IP range.
104 105 106 |
# File 'lib/ronin/support/network/asn/record.rb', line 104 def ipv6? @range.ipv6? end |
#not_routed? ⇒ Boolean
Determines if the ASN is not routed.
86 87 88 |
# File 'lib/ronin/support/network/asn/record.rb', line 86 def not_routed? @number == 0 end |
#routed? ⇒ Boolean
Determines if the ASN is routed.
77 78 79 |
# File 'lib/ronin/support/network/asn/record.rb', line 77 def routed? @number != 0 end |
#to_s ⇒ String
Converts the record into a humanly readable String.
155 156 157 158 159 160 161 |
# 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 |