Change object class

S

Seth Doe

I'm still very new to Ruby and am having trouble with a small script
that I'm working on. I am getting some data from a screen scrape using
hpricot which works well although after I get the data, I wanted to use
the result as a string but the class has changed.

When I print the class with 'puts foo.class' I get the following.

seth@oxygen seth $ ./mon_scraper.rb
Hpricot::Elem

How would I go about getting this to be

seth@oxygen seth $ ./mon_scraper.rb
String

Regards,

Seth
 
A

Alex Young

Seth said:
I'm still very new to Ruby and am having trouble with a small script
that I'm working on. I am getting some data from a screen scrape using
hpricot which works well although after I get the data, I wanted to use
the result as a string but the class has changed.

When I print the class with 'puts foo.class' I get the following.

seth@oxygen seth $ ./mon_scraper.rb
Hpricot::Elem

How would I go about getting this to be

seth@oxygen seth $ ./mon_scraper.rb
String
Use the Hpricot::Elem#to_html method.
 

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

Forum statistics

Threads
474,239
Messages
2,571,195
Members
47,831
Latest member
ClaudiaSig

Latest Threads

Top