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

Discussion in 'Ruby' started by Dennis Nedry, May 30, 2010.

  1. Dennis Nedry

    Dennis Nedry Guest

    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
     
    Dennis Nedry, May 30, 2010
    #1
    1. Advertisements

  2. Re: uninitialized constant error... trying to create a TCPsocket ina module

    On 5/30/10, Dennis Nedry <> 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.
     
    Caleb Clausen, May 31, 2010
    #2
    1. Advertisements

  3. Dennis Nedry

    Dennis Nedry Guest

    Re: uninitialized constant error... trying to create a TCPsocket ina module

    On Mon, May 31, 2010 at 2:36 AM, Caleb Clausen <> 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...


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

    -Bill Bailey
     
    Dennis Nedry, May 31, 2010
    #3
  4. Re: uninitialized constant error... trying to create a TCPsocket ina module

    2010/5/31 Dennis Nedry <>:
    > On Mon, May 31, 2010 at 2:36 AM, Caleb Clausen <> wrote:
    >>
    >> Spelled wrong, I guess. The correct name is TCPSocket, not TCPsocket.
    >>

    > Thanks. =A0I looked at that for hours and didn't notice. =A0I take it the
    > rules have been more strictly enforced in 1.9 (because that's been
    > like that for years)? =A0I'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

    --=20
    remember.guy do |as, often| as.you_can - without end
    http://blog.rubybestpractices.com/
     
    Robert Klemme, May 31, 2010
    #4
  5. Re: uninitialized constant error... trying to create a TCPsocket ina module

    Robert Klemme wrote:
    > 2010/5/31 Dennis Nedry <>:
    >> On Mon, May 31, 2010 at 2:36 AM, Caleb Clausen <> 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
     
    Joel VanderWerf, May 31, 2010
    #5
  6. Dennis Nedry

    Dennis Nedry Guest

    Re: uninitialized constant error... trying to create a TCPsocket ina module

    On Mon, May 31, 2010 at 3:33 PM, Robert Klemme
    <> wrote:
    >> Oh well, ifI was afraid of looking stupid, I'd never post...

    >
    > Well...


    yes? (;


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

    -Bill Bailey
     
    Dennis Nedry, May 31, 2010
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    13
    Views:
    13,422
    Kai-Uwe Bux
    Jan 22, 2007
  2. Martin P. Hellwig
    Replies:
    4
    Views:
    666
  3. Replies:
    2
    Views:
    272
    zycte
    Jun 15, 2006
  4. Replies:
    1
    Views:
    296
  5. Jose Pepe
    Replies:
    1
    Views:
    313
    Jose Pepe
    Jul 16, 2006
  6. Steven R.
    Replies:
    3
    Views:
    167
    Todd Werth
    Feb 14, 2007
  7. Carl Olme
    Replies:
    5
    Views:
    272
    Thomas Wieczorek
    Feb 25, 2008
  8. Bou Dramé
    Replies:
    1
    Views:
    293
    Alex Fenton
    Oct 4, 2008
Loading...