Added XML::Document#root_node
This commit is contained in:
parent
a7744b7a5c
commit
94f7f85dc3
|
@ -54,6 +54,18 @@ module Oga
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Returns self.
|
||||||
|
#
|
||||||
|
# This method exists to make this class compatible with Element, which in
|
||||||
|
# turn makes it easier to use both in the XPath compiler.
|
||||||
|
#
|
||||||
|
# @return [Oga::XML::Document]
|
||||||
|
#
|
||||||
|
def root_node
|
||||||
|
self
|
||||||
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
# Converts the document and its child nodes to XML.
|
# Converts the document and its child nodes to XML.
|
||||||
#
|
#
|
||||||
|
|
|
@ -34,6 +34,14 @@ describe Oga::XML::Document do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#root_node' do
|
||||||
|
it 'returns self' do
|
||||||
|
doc = described_class.new
|
||||||
|
|
||||||
|
doc.root_node.should == doc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#to_xml' do
|
describe '#to_xml' do
|
||||||
before do
|
before do
|
||||||
child = Oga::XML::Comment.new(:text => 'foo')
|
child = Oga::XML::Comment.new(:text => 'foo')
|
||||||
|
|
Loading…
Reference in New Issue