class Sys::Host

The Host class encapsulates information about your machine, such as

the host name and IP address.

Constants

VERSION

The version of this library. This is a string, not a number.

Public Class Methods

host_id() click to toggle source

::host_id

Returns the host id of the current machine.

static VALUE host_host_id(){
hostname click to toggle source

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

static VALUE host_hostname(){
Sys::Host.info click to toggle source
Sys::Host.info{ |i| ... }

Yields a HostInfo struct containing various bits of information about the local machine for each entry in the hosts table. In non-block form, returns an array of HostInfo structs.

The Struct::HostInfo struct contains 5 fields:

  • name (String)

  • aliases (Array)

  • addr_type (Integer) => Typically 2 (AF_INET) or 28 (AF_INET6)

  • length (Integer) => Typically 4 (IPv4) or 16 (IPv6)

  • addr_list (Array)

static VALUE host_info(VALUE klass){
ip_addr click to toggle source

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

static VALUE host_ip_addr(){