# Change object class

**URL:** <https://www.ruby-forum.com/t/change-object-class/90038>\
**Category:** Ruby\
**Created:** [March 25, 2007, 12:54pm UTC](https://www.ruby-forum.com/t/change-object-class/90038 "2007-03-25T12:54:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![uruz7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/9de0a6/32.png) [@uruz7](https://www.ruby-forum.com/u/uruz7)\
**Post date:** [March 25, 2007, 12:54pm UTC](https://www.ruby-forum.com/t/change-object-class/90038/1 "2007-03-25T12:54:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![uruz7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/9de0a6/32.png) [@uruz7](https://www.ruby-forum.com/u/uruz7)\
**Post date:** [March 25, 2007, 1:17pm UTC](https://www.ruby-forum.com/t/change-object-class/90038/2 "2007-03-25T13:17:01Z")

</div>

Seth Doe wrote:

> How would I go about getting this to be
> 
> seth@oxygen seth $ ./mon\_scraper.rb  
> String

Use the Hpricot::Elem#to\_html method.

---

<div class="post-metadata">

**Author:** ![uruz7](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/9de0a6/32.png) [@uruz7](https://www.ruby-forum.com/u/uruz7)\
**Post date:** [March 25, 2007, 1:59pm UTC](https://www.ruby-forum.com/t/change-object-class/90038/3 "2007-03-25T13:59:17Z")

</div>

Gah! Genius. Thank you.

Alex Y. wrote:

> Seth Doe wrote:
> 
> > How would I go about getting this to be
> > 
> > seth@oxygen seth $ ./mon\_scraper.rb  
> > String
> 
> Use the Hpricot::Elem#to\_html method.
