Forum: Ruby version 2.0.0, what has replaced scan?

Posted by David Bush (peyrol)
on 2013-03-07 01:07
Attachment: getgame.rb (4,32 KB)
A friend wrote a brief Ruby script (attached) which downloads game files
from a website. It worked for 1.7, but not for 2.0. Here is the error I
get:

david@achernar:~/games/Twixt/sw$ ruby ./getgame.rb 1522422 1522423
1522424 1522431
./getgame.rb:91:in `getPlayer1': undefined method `scan' for
nil:NilClass (NoMethodError)
  from ./getgame.rb:143:in `getJtwixtFileData'
  from ./getgame.rb:164:in `getGame'
  from ./getgame.rb:179:in `block in <main>'
  from ./getgame.rb:178:in `each'
  from ./getgame.rb:178:in `<main>'
david@achernar:~/games/Twixt/sw$

Is there a list of changes to Ruby since 1.7? Any clue would be
appreciated. Thanks for your time.

David
Posted by Henry Maddocks (Guest)
on 2013-03-07 01:18
(Received via mailing list)
On 7/03/2013, at 1:08 PM, David Bush <lists@ruby-forum.com> wrote:

> A friend wrote a brief Ruby script (attached) which downloads game files
> from a website. It worked for 1.7, but not for 2.0. Here is the error I
> get:
>
> david@achernar:~/games/Twixt/sw$ ruby ./getgame.rb 1522422 1522423
> 1522424 1522431
> ./getgame.rb:91:in `getPlayer1': undefined method `scan' for
> nil:NilClass (NoMethodError)

It isn't a difference between Ruby versions. You are trying to call scan 
on nil, this has never worked.

Show us the code and we might have a better idea of your problem.

Henry
Posted by Henry Maddocks (Guest)
on 2013-03-07 01:27
(Received via mailing list)
On 7/03/2013, at 1:17 PM, Henry Maddocks <hmaddocks@me.com> wrote:

>
> Show us the code and we might have a better idea of your problem.

Sorry I missed the attachment

It looks to me that you aren't being careful enough in checking the 
server responses in getGame. lgData on line 155 is nil.

Incidentally, I ran your script and it worked so maybe there was a 
transient server error.

Henry
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.