Class: Emcee::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/emcee/document.rb

Overview

Document is responsible for parsing HTML and handling interaction with the resulting document.

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Document

Returns a new instance of Document.



8
9
10
# File 'lib/emcee/document.rb', line 8

def initialize(data)
  @doc = Nokogiri::HTML5.parse("<html><body>#{data}</body></html>")
end

Instance Method Details

#html_importsObject



16
17
18
# File 'lib/emcee/document.rb', line 16

def html_imports
  wrap_nodes(@doc.css("link[rel='import']"))
end

#script_referencesObject



20
21
22
# File 'lib/emcee/document.rb', line 20

def script_references
  wrap_nodes(@doc.css("script[src]"))
end

#style_referencesObject



24
25
26
# File 'lib/emcee/document.rb', line 24

def style_references
  wrap_nodes(@doc.css("link[rel='stylesheet']"))
end

#to_sObject



12
13
14
# File 'lib/emcee/document.rb', line 12

def to_s
  unescape(replace_html_with_xhtml)
end