class Nokogiri::HTML::Document

def title=(text)

element, the title is not set.
Set the title string of this document. If there is no head
##
def title=(text)
  unless title = at('title')
    head = at('head') or return nil
    title = Nokogiri::XML::Node.new('title', self)
    head << title
  end
  title.children = XML::Text.new(text, self)
end