Class: Ronin::Support::Network::PublicSuffix::SuffixSet

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/ronin/support/network/public_suffix/suffix_set.rb

Overview

A sub-set of public suffixes.

Direct Known Subclasses

List

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Enumerable

#map_hash

Constructor Details

#initialize(suffixes = []) ⇒ SuffixSet

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.

Initializes the suffix-set.

Parameters:

  • suffixes (Enumerator::Lazy<Suffix>) (defaults to: [])

    The optional suffixes to initialize the suffix set with.



43
44
45
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 43

def initialize(suffixes=[])
  @suffixes = suffixes
end

Instance Attribute Details

#suffixesArray<Suffix>, Enumerator::Lazy<Suffix> (readonly)

The suffixes in the suffix set.

Returns:



33
34
35
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 33

def suffixes
  @suffixes
end

Instance Method Details

#<<(suffix) ⇒ self

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.

Adds a public suffix to the suffix-set.

Parameters:

  • suffix (Suffix)

    The suffix String to add.

Returns:

  • (self)


57
58
59
60
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 57

def <<(suffix)
  @suffixes << suffix
  return self
end

#each {|suffix| ... } ⇒ Enumerator

Enumerates over each suffix within the suffix-set.

Yields:

  • (suffix)

    If a block is given, it will be passed each suffix in the list.

Yield Parameters:

  • suffix (Suffix)

    A domain suffix in the list.

Returns:

  • (Enumerator)

    If no block is given, an Enumerator object will be returned.



74
75
76
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 74

def each(&block)
  @suffixes.each(&block)
end

#icannSuffixSet

Selects all ICANN suffixes.

Returns:

  • (SuffixSet)

    The new sub-set of suffixes.



97
98
99
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 97

def icann
  SuffixSet.new(lazy.select(&:icann?))
end

#lengthInteger

The number of suffixes within the suffix-set.

Returns:



136
137
138
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 136

def length
  @suffixes.length
end

#non_wildcardsSuffixSet

Selects all non-wildcard suffixes.

Returns:

  • (SuffixSet)

    The new sub-set of suffixes.



127
128
129
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 127

def non_wildcards
  SuffixSet.new(lazy.select(&:non_wildcard?))
end

#privateSuffixSet

Selects all private suffixes.

Returns:

  • (SuffixSet)

    The new sub-set of suffixes.



107
108
109
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 107

def private
  SuffixSet.new(lazy.select(&:private?))
end

#to_aArray<Suffix>

Converts the suffix-set to an Array of suffixes.

Returns:



145
146
147
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 145

def to_a
  @suffixes.to_a
end

#type(type) ⇒ SuffixSet

Selects all suffixes with the matching type.

Parameters:

  • type (:icann, :private)

    The type to filter by.

Returns:

  • (SuffixSet)

    The new sub-set of suffixes.



87
88
89
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 87

def type(type)
  SuffixSet.new(lazy.select { |suffix| suffix.type == type })
end

#wildcardsSuffixSet

Selects all wildcard suffixes.

Returns:

  • (SuffixSet)

    The new sub-set of suffixes.



117
118
119
# File 'lib/ronin/support/network/public_suffix/suffix_set.rb', line 117

def wildcards
  SuffixSet.new(lazy.select(&:wildcard?))
end