Class: Net::Ping

### Home Classes Methods

### In Files

- lib/net/ping/ping.rb

### Parent

Object

### Namespace

- CLASS Net::Ping::HTTP
- CLASS Net::Ping::ICMP
- CLASS Net::Ping::TCP
- CLASS Net::Ping::UDP
- CLASS Net::Ping::WMI

### Methods

- ::new
- #ping
- #ping?
- #pingecho

### Files

- ping.txt

### Class/Module Index

Quicksearch

- Net
- Net::Ping
- Net::Ping::External
- Net::Ping::HTTP
- Net::Ping::ICMP
- Net::Ping::TCP
- Net::Ping::UDP
- Net::Ping::WMI
- Object

No matching classes.

# Net::Ping

The Ping class serves as an abstract base class for all other Ping class types. You should not instantiate this class directly.

### Public Class Methods

new(host=nil, port=nil, timeout=5) click to toggle source

The default constructor for the Net::Ping class. Accepts an optional `host`, `port` and `timeout`. The port defaults to your echo port, or 7 if that happens to be undefined. The default timeout is 5 seconds.

The host, although optional in the constructor, must be specified at some point before the Net::Ping#ping method is called, or else an ArgumentError will be raised.

Yields `self` in block context.

This class is not meant to be instantiated directly. It is strictly meant as an interface for subclasses.

    # File lib/net/ping/ping.rb, line 57
    def initialize(host=nil, port=nil, timeout=5)
       @host      = host
       @port      = port || Socket.getservbyname('echo') || 7
       @timeout   = timeout
       @exception = nil
       @warning   = nil
       @duration  = nil

       yield self if block_given?
    end

### Public Instance Methods

ping(host = @host) click to toggle source

The default interface for the Net::Ping#ping method. Each subclass should call super() before continuing with their own implementation in order to ensure that the @exception and @warning instance variables are reset.

If `host` is nil here, then it will use the host specified in the constructor. If the `host` is nil and there was no host specified in the constructor then an ArgumentError is raised.

    # File lib/net/ping/ping.rb, line 79
    def ping(host = @host)
       raise ArgumentError, 'no host specified' unless host
       @exception = nil
       @warning   = nil
       @duration  = nil
    end

Also aliased as: ping?, pingecho
ping?(host = @host) click to toggle source
Alias for: ping
pingecho(host = @host) click to toggle source
Alias for: ping

[Validate]

Generated with the Darkfish Rdoc Generator 2.