Accessing object contents

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

On Sat, Mar 19, 2011 at 11:22 PM, John D. [email protected] wrote:

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.

John D. 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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs