class Ronin::Support::Network::ASN::RecordSet
A sub-set of ASN
records.
Attributes
The records in the record set.
@return [Array<Record>, Enumerator::Lazy<Record>]
Public Class Methods
Source
# File lib/ronin/support/network/asn/record_set.rb, line 45 def initialize(records=[]) @records = records end
Initializes the record-set.
@param [Enumerator::Lazy<Record>] records
The optional records to initialize the record set with.
@api private
Public Instance Methods
Source
# File lib/ronin/support/network/asn/record_set.rb, line 58 def <<(record) @records << record return self end
Adds a record to the record-set.
@param [Record] record
@return [self]
@api private
Source
# File lib/ronin/support/network/asn/record_set.rb, line 107 def countries set = Set.new each { |record| set << record.country_code } set end
Retruns all country codes within the record set.
@return [Set<String>]
Source
# File lib/ronin/support/network/asn/record_set.rb, line 122 def country(country_code) RecordSet.new( lazy.select { |record| record.country_code == country_code } ) end
Selects all records with the matching country code.
@param [String] country_code
The two-letter country code.
@return [RecordSet]
The new sub-set of records.
Source
# File lib/ronin/support/network/asn/record_set.rb, line 72 def each(&block) @records.each(&block) end
Enumerates over each IP
within all of the records.
@yield [record]
@yieldparam [Record] record
@return [Enumerator]
Source
# File lib/ronin/support/network/asn/record_set.rb, line 177 def include?(ip) !ip(ip).nil? end
Determines if the IP
belongs to any of the records.
@param [IPAddr, String] ip
@return [Boolean]
Source
# File lib/ronin/support/network/asn/record_set.rb, line 166 def ip(ip) find { |record| record.range.include?(ip) } end
Finds the ASN
record for the given IP
address.
@param [IP, IPaddr, String] ip
The IP address to search for.
@return [Record, nil]
The ASN record for the IP address or `nil` if none could be found.
Source
# File lib/ronin/support/network/asn/record_set.rb, line 143 def ipv4 RecordSet.new(lazy.select(&:ipv4?)) end
Selects only the records with IPv4 ranges.
@return [RecordSet]
The new sub-set of records.
Source
# File lib/ronin/support/network/asn/record_set.rb, line 153 def ipv6 RecordSet.new(lazy.select(&:ipv6?)) end
Selects only the records with IPv6 ranges.
@return [RecordSet]
The new sub-set of records.
Source
# File lib/ronin/support/network/asn/record_set.rb, line 212 def length @records.length end
The number of records within the record-set.
@return [Integer]
Source
# File lib/ronin/support/network/asn/record_set.rb, line 201 def name(name) RecordSet.new( lazy.select { |record| record.name == name } ) end
Selects all records with the matching company name.
@param [String] name
The company name to search for.
@return [RecordSet]
The new sub-set of records.
Source
# File lib/ronin/support/network/asn/record_set.rb, line 186 def names set = Set.new each { |record| set << record.name } set end
Returns all company names within the record-set.
@return [Set<String>]
Source
# File lib/ronin/support/network/asn/record_set.rb, line 96 def number(number) RecordSet.new( lazy.select { |record| record.number == number } ) end
Selects all records with the matching AS number.
@param [Integer] number
The AS number.
@return [RecordSet]
The new sub-set of records.
Source
# File lib/ronin/support/network/asn/record_set.rb, line 81 def numbers set = Set.new each { |record| set << record.number } set end
Returns all AS numbers within the record set.
@return [Set<Integer>]
Source
# File lib/ronin/support/network/asn/record_set.rb, line 133 def ranges map(&:range) end
Returns all IP
ranges within the record set.
@return [Array<IPRange::Range>]