def document
      if @document.is_a?(URI)
        # Attempt to read page. May raise HTTPError.
        options = {}
        READER_OPTIONS.each { |key| options[key] = option(key) }
        request(@document, options)
      end
      if @document.is_a?(String)
        # Parse the page. May raise HTMLParseError.
        parsed = Reader.parse_page(@document, @page_info.encoding,
                                   option(:parser_options), option(:parser))
        @document = parsed.document
        @page_info.encoding = parsed.encoding
      end
      return @document if @document.is_a?(HTML::Node)
      raise RuntimeError, "No document to process"
    end
def document
      if @document.is_a?(URI)
        # Attempt to read page. May raise HTTPError.
        options = {}
        READER_OPTIONS.each { |key| options[key] = option(key) }
        request(@document, options)
      end
      if @document.is_a?(String)
        # Parse the page. May raise HTMLParseError.
        parsed = Reader.parse_page(@document, @page_info.encoding,
                                   option(:parser_options), option(:parser))
        @document = parsed.document
        @page_info.encoding = parsed.encoding
      end
      return @document if @document.is_a?(HTML::Node)
      raise RuntimeError, "No document to process"
    end
Returns the document being processed.

 If the scraper was created with a URL, this method will attempt to
 retrieve the page and parse it.

 If the scraper was created with a string, this method will attempt
 to parse the page.

 Be advised that calling this method may raise an exception
 (HTTPError or HTMLParseError).

 The document is parsed only the first time this method is called.