class Hostname
- Hostname
- Reference
- Object
Defined in:
hostname.crhostname/resolve.cr
Constructors
-
.[](string : String) : self
Constructs a new
Hostnameby interpreting the contents of aString. -
.[]?(string : String) : self?
Constructs a new
Hostnameby interpreting the contents of aString. -
.new(parts : Array(String)) : self
Constructs a new
Hostnameby interpreting the contents of anArrayofStrings. -
.new(string : String) : self
Constructs a new
Hostnameby interpreting the contents of aString. -
.new?(string : String) : self?
Constructs a new
Hostnameby interpreting the contents of aString.
Class Method Summary
-
.new?(parts : Array(String))
Constructs a new
Hostnameby interpreting the contents of anArrayofStrings.
Instance Method Summary
-
#<=>(other : Hostname) : Int
Compares this hostname with another, returning
-1,0or+1depending if the hostname is less, equal or greater than the other hostname. - #[](index : Int) : String
-
#address(family = Socket::Family::INET, type = Socket::Type::STREAM, protocol = Protocol::IP, timeout = nil) : IP::Address
Returns the first
IP::Addressresolved for the hostname. -
#address?(family = Socket::Family::INET, type = Socket::Type::STREAM, protocol = Protocol::IP, timeout = nil) : IP::Address?
Returns the first
IP::Addressresolved for the hostname. -
#addresses(family = Socket::Family::INET, type = Socket::Type::STREAM, protocol = Protocol::IP, timeout = nil) : Array(IP::Address)
Returns an
ArrayofIP::Addresses that were resolved for the hostname. -
#child(name : String) : Hostname
Creates a new child hostname (subdomain).
-
#child?(name : String) : Hostname?
Creates a new child hostname (subdomain).
-
#each_address(family = Socket::Family::INET, type = Socket::Type::STREAM, protocol = Socket::Protocol::IP, timeout = nil, &)
Yields the
IP::Addresses that were resolved for the hostname. -
#levels : UInt32
Returns the number of levels in the hostname
-
#parent(depth : Int = 1) : Hostname
Creates the parent hostname.
-
#parent?(depth : Int = 1) : Hostname?
Creates the parent hostname.
- #parts : Array(String)
-
#resolve(family = Socket::Family::INET, type = Socket::Type::STREAM, protocol = Socket::Protocol::IP, timeout = nil, &)
Yields the
IP::Addresses,Socket::Types, andSocket:: Protocols that were resolved for the hostname. -
#size : UInt32
Returns the number of characters in the whole hostname.
-
#subdomain?(other : Hostname, fqn : Bool = false) : Bool
Indicates if the reciever is a subdomain of the given hostname.
-
#tld?(*tlds : String) : Bool
Indicates if the domain has one of the given top level domains.
-
#tld? : Bool
Indicates if the domain is a top level domain.
-
#tld?(tlds : Enumerable(String)) : Bool
Indicates if the domain has one of the given top level domains.
-
#tld?(tld : String) : Bool
Indicates if the domain has the given top level domain.
-
#to_s(fqn : Bool, io : IO) : Nil
Appends the string representation of this hostname to the given
IOwith the option of making the hostname fully qualified. -
#to_s(io : IO) : Nil
Appends the string representation of this hostname to the given
IO. -
#to_s(fqn : Bool) : String
Returns the string representation of this hostname with the option of making the hostname fully qualified.
Constructor Detail
Constructs a new Hostname by interpreting the contents of a String.
Expects an hostname like "example.com" or "example.com.".
Raises: MalformedError when the input is malformed.
Constructs a new Hostname by interpreting the contents of a String.
Expects an hostname like "example.com" or "example.com.".
Returns: nil when the input is malformed.
Constructs a new Hostname by interpreting the contents of an Array of Strings.
Expects input like: ["example", "com"].
Raises: MalformedError when the input is malformed.
Constructs a new Hostname by interpreting the contents of a String.
Expects an hostname like "example.com" or "example.com.".
Raises: MalformedError when the input is malformed.
Constructs a new Hostname by interpreting the contents of a String.
Expects an hostname like "example.com" or "example.com.".
Returns: nil when the input is malformed.
Class Method Detail
Constructs a new Hostname by interpreting the contents of an Array of Strings.
Expects input like: ["example", "com"].
Returns: nil when the input is malformed.
Instance Method Detail
Compares this hostname with another, returning -1, 0 or +1 depending if the
hostname is less, equal or greater than the other hostname.
This compares the top level alphabetically. If they match the next next level is tried.
Returns the first IP::Address resolved for the hostname.
Raises: nil if no address is found.
Returns the first IP::Address resolved for the hostname.
Returns: nil if no address is found.
Returns an Array of IP::Addresses that were resolved for the hostname.
Creates a new child hostname (subdomain).
Raises: MalformedError if the hostname is malformed.
Creates a new child hostname (subdomain).
Returns: nil if the hostname is malformed.
Yields the IP::Addresses that were resolved for the hostname.
Creates the parent hostname.
Raises: Enumerable::EmptyError if the hostname is a Top-Level-Domain.
Creates the parent hostname.
Returns: nil if the hostname is a Top-Level-Domain.
Yields the IP::Addresses, Socket::Types, and Socket:: Protocols that were resolved for the hostname.
Indicates if the reciever is a subdomain of the given hostname.
Indicates if the domain has one of the given top level domains.
Appends the string representation of this hostname to the given IO with the option
of making the hostname fully qualified.
Returns the string representation of this hostname with the option of making the hostname fully qualified.