diff --git a/lib/oga/xml/doctype.rb b/lib/oga/xml/doctype.rb index 477f7fe..e5925bf 100644 --- a/lib/oga/xml/doctype.rb +++ b/lib/oga/xml/doctype.rb @@ -27,14 +27,15 @@ module Oga def inspect(indent = 0) class_name = self.class.to_s.split('::').last + spacing = ' ' * indent return <<-EOF.strip #{class_name}( - name: #{name.inspect} - type: #{type.inspect} - public_id: #{public_id.inspect} - system_id: #{system_id.inspect} - ) +#{spacing} name: #{name.inspect} +#{spacing} type: #{type.inspect} +#{spacing} public_id: #{public_id.inspect} +#{spacing} system_id: #{system_id.inspect} +#{spacing}) EOF end end # Doctype diff --git a/lib/oga/xml/document.rb b/lib/oga/xml/document.rb index 4be2911..675dade 100644 --- a/lib/oga/xml/document.rb +++ b/lib/oga/xml/document.rb @@ -35,10 +35,22 @@ module Oga class_name = self.class.to_s.split('::').last child_lines = children.map { |child| child.inspect(4) }.join("\n") + if doctype + dtd = doctype.inspect(2) + else + dtd = doctype.inspect + end + + if xml_declaration + decl = xml_declaration.inspect(2) + else + decl = xml_declaration.inspect + end + return <<-EOF.strip #{class_name}( - doctype: #{doctype.inspect} - xml_declaration: #{xml_declaration.inspect} + doctype: #{dtd} + xml_declaration: #{decl} children: [ #{child_lines} ]) diff --git a/lib/oga/xml/xml_declaration.rb b/lib/oga/xml/xml_declaration.rb index 740b65b..0561eb5 100644 --- a/lib/oga/xml/xml_declaration.rb +++ b/lib/oga/xml/xml_declaration.rb @@ -35,15 +35,16 @@ module Oga end - def inspect + def inspect(indent = 0) class_name = self.class.to_s.split('::').last + spacing = ' ' * indent return <<-EOF.strip #{class_name}( - version: #{version.inspect} - encoding: #{encoding.inspect} - standalone: #{standalone.inspect} - ) +#{spacing} version: #{version.inspect} +#{spacing} encoding: #{encoding.inspect} +#{spacing} standalone: #{standalone.inspect} +#{spacing}) EOF end end # XmlDeclaration