Class

Resolv::DNS::Name

Inheritance
< Object

A representation of a DNS name.

Aliases

Method Alias Description
== → eql?

Methods

Class

Visibility Signature
public create (arg)

Instance

Visibility Signature
public absolute? ()
public subdomain_of? (other)
public to_s ()

Class Method Detail

create(arg)

Creates a new DNS name from arg. arg can be:

Name:returns arg.
String:Creates a new Name.

Instance Method Detail

absolute?()

True if this name is absolute.

subdomain_of?(other)

Returns true if other is a subdomain.

Example:

  domain = Resolv::DNS::Name.create("y.z")
  p Resolv::DNS::Name.create("w.x.y.z").subdomain_of?(domain) #=> true
  p Resolv::DNS::Name.create("x.y.z").subdomain_of?(domain) #=> true
  p Resolv::DNS::Name.create("y.z").subdomain_of?(domain) #=> false
  p Resolv::DNS::Name.create("z").subdomain_of?(domain) #=> false
  p Resolv::DNS::Name.create("x.y.z.").subdomain_of?(domain) #=> false
  p Resolv::DNS::Name.create("w.z").subdomain_of?(domain) #=> false

to_s()

returns the domain name as a string.

The domain name doesn‘t have a trailing dot even if the name object is absolute.

Example:

  p Resolv::DNS::Name.create("x.y.z.").to_s #=> "x.y.z"
  p Resolv::DNS::Name.create("x.y.z").to_s #=> "x.y.z"