Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > accessing object contents

Reply
Thread Tools

accessing object contents

 
 
John Doe
Guest
Posts: n/a
 
      03-19-2011
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/.

 
Reply With Quote
 
 
 
 
Mayank Kohaley
Guest
Posts: n/a
 
      03-19-2011
[Note: parts of this message were removed to make it a legal post.]

On Sat, Mar 19, 2011 at 11:22 PM, John Doe <(E-Mail Removed)> wrote:

> 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/.
>
>


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

 
Reply With Quote
 
 
 
 
Brian Candler
Guest
Posts: n/a
 
      03-19-2011
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.

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding contents on yaml file without overwriting actual contents Kamarulnizam Rahim Ruby 4 01-28-2011 09:10 AM
Re: Accessing the contents of a 'cell' object from Python Jeff Epler Python 1 03-16-2005 10:01 AM
Re: Accessing the contents of a 'cell' object from Python paul cannon Python 0 03-16-2005 12:12 AM
Accessing the contents of a 'cell' object from Python paul cannon Python 0 03-15-2005 10:08 PM
Can I restrict both attribute contents and element contents in schema Don Adams XML 1 03-05-2004 12:48 PM



Advertisments