class Ronin::Support::Network::Wildcard

Represents a wildcard hostname.

## Examples

wildcard = Network::Wildcard.new('*.example.com')
wildcard.subdomain('www')
# => #<Ronin::Support::Network::Host: www.example.com>

@api public

@since 1.1.0

Attributes

template[R]

The wildcard template for the hostname.

@return [String]

Public Class Methods

new(template) click to toggle source

Initializes the wildcard hostname.

@param [String] template

The wildcard hostname template.

@example

wildcard = Network::Wildcard.new('*.example.com')
# File lib/ronin/support/network/wildcard.rb, line 53
def initialize(template)
  @template = template
end

Public Instance Methods

subdomain(name) click to toggle source

Replaces the ‘*` in the wildcard hostname with the given name.

@param [String] name

The name to replace the `*` wildcard with.

@return [Host]

The new hostname.

@example

wildcard = Network::Wildcard.new('*.example.com')
wildcard.subdomain('www')
# => #<Ronin::Support::Network::Host: www.example.com>
# File lib/ronin/support/network/wildcard.rb, line 71
def subdomain(name)
  Host.new(@template.sub('*',name))
end
to_s() click to toggle source

Converts the wildcard hostname to a String.

@return [String]

The string value of the wildcard hostname.
# File lib/ronin/support/network/wildcard.rb, line 81
def to_s
  @template
end