From: Daniel N Date: 2007-08-23T11:21:02+09:00 Subject: Re: Class method access instance variable? ------=_Part_45651_25851383.1187835661077 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 8/23/07, Finn Koch wrote: > > Hi, I'm just learning ruby and I'm working on a server connection. I > have the following code: > > class IRCBot > > .... > > > def connect > puts "Connecting to #{@server}..." > @conn = TCPSocket.new( @server, @port ) > handle_server_registration > end > end > > > I have another class that needs to perform a '@conn.send("asdf",0)'. > Can anyone help me figure out how I can have this external class access > the @conn instance variable? > > Thanks! > > upenox > -- Don't access the @conn instance variable directly. Use an attr_accessor in the class IRCBot and the just ask for the @irc_bot_instance.conn HTH Daniel ------=_Part_45651_25851383.1187835661077--