Update 2026: This is no longer the way Nokogiri works. As per the Nokogiri documentation, you can now get the document type by simply using .html? or .xml?
Say you have a Nokogiri document, for example through:
doc = Nokogiri::HTML(open(index.html))
When you now call doc.type, a digit will be returned, in this case 13.
What document type this translates to can be seen here:
(link that was here, but no longer valid: http://www.rubydoc.info/github/sparklemotion/nokogiri/Nokogiri/XML/Node#DOCUMENT_TYPE_NODE-constant)
Notable examples:
9 - XML document
13 - HTML document