Module: Taka::DOM::HTML::Document
- Defined in:
- lib/taka/dom/html/document.rb
Instance Method Summary collapse
- #anchors ⇒ Object
- #applets ⇒ Object
- #body ⇒ Object
- #close ⇒ Object
-
#cookie ⇒ Object
The cookies associated with this document.
-
#domain ⇒ Object
The domain name of the server that served the document, or a null string if the server cannot be identified by a domain name.
- #forms ⇒ Object
- #getElementsByName(name) ⇒ Object
- #images ⇒ Object
- #links ⇒ Object
- #open ⇒ Object
-
#referrer ⇒ Object
Returns the URI of the page that linked to this page.
- #title ⇒ Object
- #URL ⇒ Object
- #write(string) ⇒ Object
- #writeln(string) ⇒ Object
Instance Method Details
#anchors ⇒ Object
46 47 48 |
# File 'lib/taka/dom/html/document.rb', line 46 def anchors xpath('.//a[@name]') end |
#applets ⇒ Object
30 31 32 |
# File 'lib/taka/dom/html/document.rb', line 30 def applets xpath('.//object[applet]', './/applet') end |
#body ⇒ Object
22 23 24 |
# File 'lib/taka/dom/html/document.rb', line 22 def body at('.//body') end |
#close ⇒ Object
75 76 77 78 79 80 81 82 |
# File 'lib/taka/dom/html/document.rb', line 75 def close @tmp_doc ||= nil return unless @tmp_doc Nokogiri::HTML.fragment(@tmp_doc || '').each { |node| document.add_child node } @tmp_doc = nil end |
#cookie ⇒ Object
The cookies associated with this document. If there are none, the value is an empty string. Otherwise, the value is a string: a semicolon-delimited list of “name, value” pairs for all the cookies associated with the page. For example, name=value;expires=date.
54 55 56 |
# File 'lib/taka/dom/html/document.rb', line 54 def '' end |
#domain ⇒ Object
The domain name of the server that served the document, or a null string if the server cannot be identified by a domain name.
18 19 20 |
# File 'lib/taka/dom/html/document.rb', line 18 def domain '' end |
#forms ⇒ Object
42 43 44 |
# File 'lib/taka/dom/html/document.rb', line 42 def forms xpath('.//form') end |
#getElementsByName(name) ⇒ Object
58 59 60 |
# File 'lib/taka/dom/html/document.rb', line 58 def getElementsByName name xpath(".//*[@name='#{name}']") end |
#images ⇒ Object
26 27 28 |
# File 'lib/taka/dom/html/document.rb', line 26 def images xpath('.//img') end |
#links ⇒ Object
38 39 40 |
# File 'lib/taka/dom/html/document.rb', line 38 def links xpath('.//area[@href]', './/a[@href]') end |
#open ⇒ Object
62 63 64 |
# File 'lib/taka/dom/html/document.rb', line 62 def open children.each { |child| child.unlink } end |
#referrer ⇒ Object
Returns the URI of the page that linked to this page. The value is an empty string if the user navigated to the page directly (not through a link, but, for example, via a bookmark).
12 13 14 |
# File 'lib/taka/dom/html/document.rb', line 12 def referrer '' end |
#title ⇒ Object
5 6 7 |
# File 'lib/taka/dom/html/document.rb', line 5 def title at('.//title').text end |
#URL ⇒ Object
34 35 36 |
# File 'lib/taka/dom/html/document.rb', line 34 def URL url end |
#write(string) ⇒ Object
66 67 68 69 |
# File 'lib/taka/dom/html/document.rb', line 66 def write string @tmp_doc ||= '' @tmp_doc << string end |
#writeln(string) ⇒ Object
71 72 73 |
# File 'lib/taka/dom/html/document.rb', line 71 def writeln string write("#{string}\n") end |