Class: Ronin::Support::Network::Wildcard

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/support/network/wildcard.rb

Overview

Represents a wildcard hostname.

Examples

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

Since:

  • 1.1.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ Wildcard

Initializes the wildcard hostname.

Examples:

wildcard = Network::Wildcard.new('*.example.com')

Parameters:

  • template (String)

    The wildcard hostname template.

Since:

  • 1.1.0



53
54
55
# File 'lib/ronin/support/network/wildcard.rb', line 53

def initialize(template)
  @template = template
end

Instance Attribute Details

#templateString (readonly)

The wildcard template for the hostname.

Returns:

Since:

  • 1.1.0



42
43
44
# File 'lib/ronin/support/network/wildcard.rb', line 42

def template
  @template
end

Instance Method Details

#subdomain(name) ⇒ Host

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

Examples:

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

Parameters:

  • name (String)

    The name to replace the * wildcard with.

Returns:

  • (Host)

    The new hostname.

Since:

  • 1.1.0



71
72
73
# File 'lib/ronin/support/network/wildcard.rb', line 71

def subdomain(name)
  Host.new(@template.sub('*',name))
end

#to_sString

Converts the wildcard hostname to a String.

Returns:

  • (String)

    The string value of the wildcard hostname.

Since:

  • 1.1.0



81
82
83
# File 'lib/ronin/support/network/wildcard.rb', line 81

def to_s
  @template
end