Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

uninitialized constant error... trying to create a TCPsocket in a module

16 views
Skip to first unread message

Dennis Nedry

unread,
May 30, 2010, 5:31:37 PM5/30/10
to
Okay, forget about the editor thing.. (;

Trying to convert the BBS to 1.9. I've run into a weird problem with
some code I didn't write...

basically, I'm getting an error trying to create a TCPsocket..

/home/mark/qbbs2/chat/common.rb:40:in `initialize': uninitialized
constant Chat::Client::TCPsocket (NameError)

I've been looking on the web, and it looks like there have been
scoping changes, but I'm not quite sure how to fix it. Excerpts
below...

except from irc.rb

require 'chat/common'

require 'chat/irc/command'
require 'chat/irc/event'
require 'chat/irc/message'
require 'chat/irc/numeric'
require 'chat/irc/security'

module IRC

# IRC client data
class Client < Chat::Client

def initialize(host="localhost", port=6667)
super
@irccmd = IRC::Command.new
end

exerpt from common.rb

require 'observer'

require 'socket'


module Chat

# Basic client components

class Client

# Include changed/notify_observers methods.

include Observable

def initialize(host, port)

@sock = TCPsocket.new(host, port)

end

--
"I've got ham but I'm not a hamster."

-Bill Bailey

Caleb Clausen

unread,
May 30, 2010, 9:36:16 PM5/30/10
to
On 5/30/10, Dennis Nedry <den...@cortex-media.info> wrote:
> Okay, forget about the editor thing.. (;
>
> Trying to convert the BBS to 1.9. I've run into a weird problem with
> some code I didn't write...
>
> basically, I'm getting an error trying to create a TCPsocket..
>
> /home/mark/qbbs2/chat/common.rb:40:in `initialize': uninitialized
> constant Chat::Client::TCPsocket (NameError)
>
> I've been looking on the web, and it looks like there have been
> scoping changes, but I'm not quite sure how to fix it. Excerpts
> below...
[snip]

> def initialize(host, port)
>
> @sock = TCPsocket.new(host, port)
>
> end

Spelled wrong, I guess. The correct name is TCPSocket, not TCPsocket.

Dennis Nedry

unread,
May 31, 2010, 7:21:29 AM5/31/10
to
On Mon, May 31, 2010 at 2:36 AM, Caleb Clausen <vik...@gmail.com> wrote:
>
> Spelled wrong, I guess. The correct name is TCPSocket, not TCPsocket.
>
>
Thanks. I looked at that for hours and didn't notice. I take it the
rules have been more strictly enforced in 1.9 (because that's been
like that for years)? I've never really cared for capitalisation
making a difference...

Oh well, ifI was afraid of looking stupid, I'd never post...

Robert Klemme

unread,
May 31, 2010, 10:33:39 AM5/31/10
to
2010/5/31 Dennis Nedry <den...@cortex-media.info>:

> On Mon, May 31, 2010 at 2:36 AM, Caleb Clausen <vik...@gmail.com> wrote:
>>
>> Spelled wrong, I guess. The correct name is TCPSocket, not TCPsocket.
>>
> Thanks.  I looked at that for hours and didn't notice.  I take it the
> rules have been more strictly enforced in 1.9 (because that's been
> like that for years)?  I've never really cared for capitalisation
> making a difference...

Capitalization of identifiers *always* made a difference in Ruby!
("always" meaning "as long as I use Ruby, which is somewhere since
1.8.x" - but I doubt such a crucial feature has changed before; if at
all then I guess in one of 0.x versions.)

> Oh well, ifI was afraid of looking stupid, I'd never post...

Well...

Cheers

robert

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Joel VanderWerf

unread,
May 31, 2010, 1:24:13 PM5/31/10
to
Robert Klemme wrote:
> 2010/5/31 Dennis Nedry <den...@cortex-media.info>:
>> On Mon, May 31, 2010 at 2:36 AM, Caleb Clausen <vik...@gmail.com> wrote:
>>> Spelled wrong, I guess. The correct name is TCPSocket, not TCPsocket.
>>>
>> Thanks. I looked at that for hours and didn't notice. I take it the
>> rules have been more strictly enforced in 1.9 (because that's been
>> like that for years)? I've never really cared for capitalisation
>> making a difference...
>
> Capitalization of identifiers *always* made a difference in Ruby!
> ("always" meaning "as long as I use Ruby, which is somewhere since
> 1.8.x" - but I doubt such a crucial feature has changed before; if at
> all then I guess in one of 0.x versions.)

Almost always:

$ ruby -v -r socket -e 'p TCPSocket, TCPsocket'
ruby 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux]
TCPSocket
TCPSocket


Dennis Nedry

unread,
May 31, 2010, 6:44:20 PM5/31/10
to
On Mon, May 31, 2010 at 3:33 PM, Robert Klemme
<short...@googlemail.com> wrote:
>> Oh well, ifI was afraid of looking stupid, I'd never post...
>
> Well...

yes? (;

0 new messages