[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Strange StringScanner behaviour

Neowulf

12/22/2005 9:42:00 AM

Hi all,

I have a really bad feeling about posting this here, but I'm kinda
stumped.

I've only just discovered the wonder that is ruby and so have started
playing around with a number of projects.

One of them involves doing a little string parsing (as you'd expect).

However, when I try to make use of the StringScanner from the core API,
I get the strangest message:

NameError: uninitialized constant StringScanner

To put it in context:

!#/usr/bin/ruby -w

s = StringScanner.new("My test string")

I know... not exactally rocket science here. I just don't understand
why it's not working. Perhaps a corrupt installation?

I can't for the life of me figure out what I'm doing wrong...

I'm running the latest stable release of ruby (that I know of)
ruby 1.8.3 (2005-09-21) [i386-linux]

I get the same problem when attempting to test the code with irb.

Any thoughts suggestions would be greatly appreciated.

Best regards,
~Neowulf

--
Posted via http://www.ruby-....


15 Answers

Dan Diebolt

12/22/2005 9:48:00 AM

0

>NameError: uninitialized constant StringScanner

require 'strscan'
s = StringScanner.new("My test string")



__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail...

Neowulf

12/22/2005 12:41:00 PM

0

Thanks Dan,

I feel like a right idiot.

I suspected it'd be something simple

The API docs weren't real clear to me about which library to include.

Thanks again for the assistance.

~Neowulf

James Gray

12/22/2005 1:54:00 PM

0

On Dec 22, 2005, at 3:41 AM, Neowulf wrote:

> Hi all,

Howdy.

> I have a really bad feeling about posting this here, but I'm kinda
> stumped.

Ah, don't say that. We're pretty nice and almost never bite. ;)

Feel free to ask future questions.

> However, when I try to make use of the StringScanner from the core
> API,

I know you've already got an answer, but this is the source of your
confusion and I thought I would see if I could clear it up for you.

Everything that is "Core Ruby" can be used without a require. Now
Ruby also ships with a "Standard Library", which is a collection of
useful extra libraries you can also use (but with a require).
StringScanner is a Standard Library.

You can tell by looking at which link they are documented under, from
this page:

http://www.rub...

Hope that helps.

James Edward Gray II



Neowulf

12/22/2005 2:28:00 PM

0

Hi James,

Thanks for the additional information. That makes things much clearer.

Though I greatly appreciate the help, I'll try to keep the annoying
questions to a minimum :)

Does the brain good to do some thinking on ones own sometimes :)

I'll be sure to call again should I hit another wall.

My current exercise is creating a script to scan through my systems log
files and autoblock the script kiddies who insist on trying their luck
with my SSH server.

Seemed like a nice, simple way to try out a few different ideas with
Ruby.

Might even post it when I'm done and see what you guys think.

We'll see how it goes :)

Thanks again.

~Neowulf

Anandh Kumar

6/15/2009 9:29:00 AM

0

Anandh Kumar wrote:
>
> Hi everybody
>
>
>
> Can the Stringscanner be also used in linux and also can it be used
> in parsing the particular open office document... if so how should i call that document...

--
Posted via http://www.ruby-....

Anandh Kumar

6/16/2009 6:56:00 AM

0



Hi everybody


I've to parse the open office documents and upload it to the
database in ruby on rails and in linux platform. I've not found any gem
to accomplish that. Now i got a idea of converting the open office
documents to XML format and then to parse the XML content to finish up
with my task.



Is it possible?

Is there standard ruby on rails libraries to do this task?


Guide me in achieving this...




Thanks in advance

Anandh




--
Posted via http://www.ruby-....

Robert Klemme

6/16/2009 8:18:00 AM

0

2009/6/16 Anandh Kumar <anandhthiyagarajan@gmail.com>:
> =A0 =A0 =A0I've to parse the open office documents and upload it to the
> database in ruby on rails and in linux platform. I've not found any gem
> to accomplish that. Now i got a idea of converting the open office
> documents to XML format and then to parse the XML content to finish up
> with my task.
>
> =A0 =A0 =A0 Is it possible?
>
> =A0 =A0 =A0 Is there standard ruby on rails libraries to do this task?
>
> =A0 =A0 Guide me in achieving this...

What do you mean by "upload to the database"? Do you want to store it
as blob, in an XML enabled database, as plain text, as...?

Btw, it never hurts to include "please" when asking for something.
Please help keep this a friendly place.

Cheers

robert

--=20
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestprac...

Anandh Kumar

6/16/2009 8:29:00 AM

0


Thanks for your kind reply. I've to create a open office.org document
containing the students details such as name,registernumber etc. Then
i've to parse these strings and map these details into the corresponding
table in the database. can you please guide me in accomplishing this
task.





Thanks in advance


Anandh








--
Posted via http://www.ruby-....

kranthi reddy

6/16/2009 9:15:00 AM

0

[Note: parts of this message were removed to make it a legal post.]

Hey,
You can use LibXML-Ruby 1.1.2, Hpricot or REXML for parsing the xml and
retrieving the data.

http://code.whytheluckystiff.net/do... -Hpricot
http://www.ruby-doc.org/stdlib/libdoc/rexml/rdoc/... -REXML
http://libxml.rubyforge.org/rdoc/... -LibXML

From the above links you find the required information.




On Tue, Jun 16, 2009 at 1:58 PM, Anandh Kumar
<anandhthiyagarajan@gmail.com>wrote:

>
> Thanks for your kind reply. I've to create a open office.org document
> containing the students details such as name,registernumber etc. Then
> i've to parse these strings and map these details into the corresponding
> table in the database. can you please guide me in accomplishing this
> task.
>
>
>
>
>
> Thanks in advance
>
>
> Anandh
>
>
>
>
>
>
>
>
> --
> Posted via http://www.ruby-....
>
>


--
Thank you
kranthi
http://monkeydevel.wor...

Christopher Dicely

6/16/2009 1:48:00 PM

0

On Mon, Jun 15, 2009 at 11:56 PM, Anandh
Kumar<anandhthiyagarajan@gmail.com> wrote:
>
>
> Hi everybody
>
>
> =C2=A0 =C2=A0 =C2=A0I've to parse the open office documents and upload it=
to the
> database in ruby on rails and in linux platform. I've not found any gem
> to accomplish that. Now i got a idea of converting the open office
> documents to XML format and then to parse the XML content to finish up
> with my task.

Isn't OOo's native format ODF, which is an XML format? So why do you
need to convert it to XML?