This repository has been archived by the owner. It is now read-only.
djberg96 edited this page Sep 13, 2010 · 2 revisions

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.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.