From: Simon Krahnke Date: 2007-08-24T03:53:28+09:00 Subject: Re: Class method access instance variable? * Finn Koch (04:38) schrieb: > I have tried this, with no luck. I have an external file that creates > the new instance of IRCBot: Stop thinking of files, Ruby is about objects, it doesn't in which files statements are, as long as they are processed. > mybot = IRCBot.new mybot is a local variable now. > I tried referring to it as 'mybot.conn.send("asdf", 0)', but that didn't > work. What do you mean, what happended? Does IRCBot have an conn method? What happens if you use mybot.conn? [1] > class IRCCallback > def self.check_next( input ) > mybot.conn.send("PRIVMSG matt-mb :hey-o", 0) > puts "irc callback working" > end > > end There is no local variable mybot here. Call it $mybot if you want global variables, but you really shouldn't want that. Try: class IRCCallback attr_accessor :bot def self.check_next( input ) @bot.conn.send("PRIVMSG matt-mb :hey-o", 0) puts "irc callback working" end end IRCCallback.bot = IRCBot.new mfg, simon .... l [1] Why the hell did BasicSocket redefine Object#send?