J
Jonathan D. Proulx
Hi,
just to try and wrap my head around ruby I'm attempting to build a
Net::Finger (as a subclass of TCPSocket) class based on the network
I/O example in "Programming Ruby", but my class behave exacly like
it's superclass, where I have 3 (optional?) parameters to initialize
it demands the 2 parameters of the superclass. Any help would be
mutch appriciated.
What am I not seeing/understanding? Here's the code
require 'socket'
module Net
class Finger < TCPSocket
def initialize(who=nil,where="localhost",max_retry=3)
super(where,"finger")
@who, @where, @max_retry = who, where, max_retry
@try = 0
if ! who
@who, @where = gets("who@where? ").split(/@/)
end
end
<more stuff...>
end
end
and here is the behavior from within irb:
irb(main):002:0> fingerme=Net::Finger.new("jon", "csail.mit.edu")
SocketError: getaddrinfo: Servname not supported for ai_socktype
from (irb):2:in `new'
from (irb):2
irb(main):003:0> fingerme=Net::Finger.new("csail.mit.edu","finger")
#<Net::Finger:0x4028b31c>
irb(main):004:0> fingerme.send("jon\n",0)
4
irb(main):005:0> puts fingerme.readlines()
JON Jonathan D. Proulx - Research staff
Thanks,
-Jon
just to try and wrap my head around ruby I'm attempting to build a
Net::Finger (as a subclass of TCPSocket) class based on the network
I/O example in "Programming Ruby", but my class behave exacly like
it's superclass, where I have 3 (optional?) parameters to initialize
it demands the 2 parameters of the superclass. Any help would be
mutch appriciated.
What am I not seeing/understanding? Here's the code
require 'socket'
module Net
class Finger < TCPSocket
def initialize(who=nil,where="localhost",max_retry=3)
super(where,"finger")
@who, @where, @max_retry = who, where, max_retry
@try = 0
if ! who
@who, @where = gets("who@where? ").split(/@/)
end
end
<more stuff...>
end
end
and here is the behavior from within irb:
irb(main):002:0> fingerme=Net::Finger.new("jon", "csail.mit.edu")
SocketError: getaddrinfo: Servname not supported for ai_socktype
from (irb):2:in `new'
from (irb):2
irb(main):003:0> fingerme=Net::Finger.new("csail.mit.edu","finger")
#<Net::Finger:0x4028b31c>
irb(main):004:0> fingerme.send("jon\n",0)
4
irb(main):005:0> puts fingerme.readlines()
JON Jonathan D. Proulx - Research staff
Thanks,
-Jon