undefined method `each'

R

Russ F.

Before I explain the issue I=E2=80=99m having I should preface it with so=
me
important information. I=E2=80=99m a novice programmer at best and I=E2=80=
=99m new to
Ruby=E2=80=A6

I=E2=80=99m trying to capture the authentication token from Nessus so I c=
an use
it to run scans, reports, etc. I found the following code on the Nessus
site but I=E2=80=99m getting =E2=80=9Cundefined method `each' for
#<String:0x00000001458a10> (NoMethodError)=E2=80=9D from a line of code n=
ear the
bottom (response.body.each do |line|). I=E2=80=99m using Ruby 1.9.1 runn=
ing on
Linux (Ubuntu 10.04). Any insight you can provide would be much
appreciated!

Attachments:
http://www.ruby-forum.com/attachment/5266/Nessus_logon.txt


-- =

Posted via http://www.ruby-forum.com/.=
 
B

Brian Candler

Russ Forsythe wrote in post #958057:
Before I explain the issue I=E2=80=99m having I should preface it with = some
important information. I=E2=80=99m a novice programmer at best and I=E2= =80=99m new to
Ruby=E2=80=A6

I=E2=80=99m trying to capture the authentication token from Nessus so I= can use
it to run scans, reports, etc. I found the following code on the Nessu= s
site but I=E2=80=99m getting =E2=80=9Cundefined method `each' for
#<String:0x00000001458a10> (NoMethodError)=E2=80=9D from a line of code= near the
bottom (response.body.each do |line|). I=E2=80=99m using Ruby 1.9.1 ru= nning on
Linux (Ubuntu 10.04). Any insight you can provide would be much
appreciated!

ruby 1.8 had String#each, ruby 1.9 does not. Use String#each_line =

instead.

(However, strangely, IO#each still exists)

-- =

Posted via http://www.ruby-forum.com/.=
 
A

Adrian Tepes

Russ Forsythe wrote in post #958057:
Before I explain the issue I=E2=80=99m having I should preface it with = some
important information. I=E2=80=99m a novice programmer at best and I=E2= =80=99m new to
Ruby=E2=80=A6

I=E2=80=99m trying to capture the authentication token from Nessus so I= can use
it to run scans, reports, etc. I found the following code on the Nessu= s
site but I=E2=80=99m getting =E2=80=9Cundefined method `each' for
#<String:0x00000001458a10> (NoMethodError)=E2=80=9D from a line of code= near the
bottom (response.body.each do |line|). I=E2=80=99m using Ruby 1.9.1 ru= nning on
Linux (Ubuntu 10.04). Any insight you can provide would be much
appreciated!

Hi
It seem that the method "each" in String has been removed from version =

1.9.*,you can see the build-in method declaration in string.c:

rb_define_method(rb_cString, "each_line", rb_str_each_line, -1);
rb_define_method(rb_cString, "each_byte", rb_str_each_byte, 0);
rb_define_method(rb_cString, "each_char", rb_str_each_char, 0);
rb_define_method(rb_cString, "each_codepoint", =

rb_str_each_codepoint, 0);

There is no "each",use "each_line" or others instead.

-- =

Posted via http://www.ruby-forum.com/.=
 
R

Russ Forsythe

Wow, I didn't expect that to be the issue. I'll give it a try with
"each_line". Thanks so much for your help!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top