Class: Nekohtml::HtmlThing
- Inherits:
-
Object
- Object
- Nekohtml::HtmlThing
show all
- Defined in:
- lib/nekohtml/html_document.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(java_object) ⇒ HtmlThing
Returns a new instance of HtmlThing.
5
6
7
8
9
10
|
# File 'lib/nekohtml/html_document.rb', line 5
def initialize(java_object)
@java_object = java_object
@jxpath_factory =
javax.xml.xpath.XPathFactory.newInstance()
end
|
Instance Attribute Details
#java_object ⇒ Object
Returns the value of attribute java_object.
4
5
6
|
# File 'lib/nekohtml/html_document.rb', line 4
def java_object
@java_object
end
|
Instance Method Details
#at(xpath) ⇒ Object
33
34
35
36
37
38
|
# File 'lib/nekohtml/html_document.rb', line 33
def at(xpath)
@jxpath_settings = javax.xml.xpath.XPathConstants::NODE
jnode = self.do_search(xpath, @jxpath_settings)
result = jnode ? HtmlNode.new(jnode) : nil
end
|
#do_search(xpath, settings) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/nekohtml/html_document.rb', line 12
def do_search(xpath, settings)
jxpath_object = @jxpath_factory.newXPath()
jmaybe_node_list = begin
jxpath_object.evaluate(
xpath,
@java_object,
settings
)
rescue
nil
end
return jmaybe_node_list
end
|
#search(xpath) ⇒ Object
26
27
28
29
30
31
|
# File 'lib/nekohtml/html_document.rb', line 26
def search(xpath)
@jxpath_settings = javax.xml.xpath.XPathConstants::NODESET
jnode_list = self.do_search(xpath, @jxpath_settings)
result = jnode_list ? HtmlNodeList.new(jnode_list) : nil
end
|