Class: Net::Ping

Inherits:
Object
  • Object
show all
Defined in:
lib/net/ping.rb

Overview

An abstract base class. Do not instantiate directly.

Direct Known Subclasses

PingExternal, PingHTTP, PingTCP, PingUDP

Constant Summary collapse

VERSION =
"1.1.1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port = nil, timeout = 5) ⇒ Ping

Returns a new instance of Ping.



11
12
13
14
15
16
17
18
# File 'lib/net/ping.rb', line 11

def initialize(host, port=nil, timeout=5)
   @host    = host
   @port    = port || Socket.getservbyname("echo") || 7
   @timeout = timeout
   @data    = "ping"
   @exception = nil
   @warning   = nil
end

Instance Attribute Details

#exceptionObject (readonly)

Returns the value of attribute exception.



9
10
11
# File 'lib/net/ping.rb', line 9

def exception
  @exception
end

#hostObject

Returns the value of attribute host.



8
9
10
# File 'lib/net/ping.rb', line 8

def host
  @host
end

#portObject

Returns the value of attribute port.



8
9
10
# File 'lib/net/ping.rb', line 8

def port
  @port
end

#timeoutObject

Returns the value of attribute timeout.



8
9
10
# File 'lib/net/ping.rb', line 8

def timeout
  @timeout
end

#warningObject (readonly)

Returns the value of attribute warning.



9
10
11
# File 'lib/net/ping.rb', line 9

def warning
  @warning
end

Instance Method Details

#pingObject



20
21
22
23
# File 'lib/net/ping.rb', line 20

def ping
   @exception = nil
   @warning   = nil
end