Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

accessing object contents

5 views
Skip to first unread message

John Doe

unread,
Mar 19, 2011, 1:52:55 PM3/19/11
to
given
=> #<Dnsruby::Name: www.nbc.com.>

what's the proper way of getting to "www.nbc.com."? is it
with the to_s method?

obj.to_s

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

Mayank Kohaley

unread,
Mar 19, 2011, 2:10:52 PM3/19/11
to
[Note: parts of this message were removed to make it a legal post.]

Override the to_s method in your class and define it to print out the value
of variable. Then you can call to_s method on the object.
--
Mayank Kohaley

Brian Candler

unread,
Mar 19, 2011, 5:20:30 PM3/19/11
to
John Doe wrote in post #988311:

> given
> => #<Dnsruby::Name: www.nbc.com.>

Is that output from irb? irb uses the "inspect" method to display a
value.

> what's the proper way of getting to "www.nbc.com."?

Depends entirely on the class in question. Look at the documentation for
Dnsruby::Name, or at the source code, to see what methods are available.

0 new messages