Skip to content
This repository

sys-host

The sys-host library provides various bits of information about your host.

Synopsis

  require 'sys/host'
  include Sys

  p Host.hostname
  p Host.ip_addr
  p Host.host_id

  # Some platforms
  Host.info{ |h|
    p h
  }

Constants

VERSION

Returns the current version number of this library (as a string)

Singleton Methods

Host.hostname

Returns the hostname of the current host. This may or not return the FQDN, depending on your system.

Host.ip_addr

Returns a list of IP addresses for the current host (yes, it is possible to have more than one).

Host.info(host=localhost)
Host.info(host=localhost){ |h| … }

Yields a HostInfo struct for each network adapter on ‘host’, or an array of HostInfo struct’s in non-block form. The exact members of this struct vary depending on your platform.

Host.host_id

Returns the unique hexadecimal identifier for the current host.

Exception Classes

Host::Error < StandardError

Raised in the event of a failure for any of the class methods provided with this library. Generally speaking, it means there was a failure in the underlying gethostname() or gethostbyname() calls.

Something went wrong with that request. Please try again.