String vs Record

The initial version of the Whois library returned the response as a simple String. However, a String is a really simple object and isn't a good candidate for storing a complex and multipart element such as a WHOIS response.

Let me explain why.

You have to know that a WHOIS response might be the result of multiple WHOIS requests. For instance, when the WHOIS interface uses the Thin data model, one WHOIS server stores only the name of the WHOIS server of the registrar of a domain, which in turn has the full details on the data being looked up (such as the .com WHOIS servers, which refer the WHOIS query to the registrar where the domain was registered). In this case, Whois needs to recursively contact all hosts in order to compose the final response.

Instead of merging all the responses altogether into a single String, the Whois::Record object preserve the information about each part of the response as Whois::Record::Part instance so you can easily access them.

# Example: Similarities between a String and a Whois::Record instance
r = Whois.whois("google.com")
# the following statement
puts r.to_s
# is equal to
puts r
# which is equal to
puts r.content
# which means
puts r.parts.map(&:response).join("\n")