Trimmed XML inspect values.
This commit is contained in:
1 parent
26d4bdc5b1
commit
d7df908649
9 files changed
+57
-74
No files matched your search
@@ -42,8 +42,17 @@ module Oga
|
||||
# @return [String]
|
||||
#
|
||||
def inspect
|
||||
return "Attribute(name: #{name.inspect} " \
|
||||
"namespace: #{namespace.inspect} value: #{value.inspect})"
|
||||
segments = []
|
||||
|
||||
[:name, :namespace, :value].each do |attr|
|
||||
value = send(attr)
|
||||
|
||||
if value and !value.empty?
|
||||
segments << "#{attr}: #{value.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
return "Attribute(#{segments.join(' ')})"
|
||||
end
|
||||
end # Attribute
|
||||
end # XML
|
||||
|
||||
+11
-13
@@ -64,22 +64,20 @@ module Oga
|
||||
##
|
||||
# Inspects the doctype.
|
||||
#
|
||||
# @param [Fixnum] indent The indentation level for each line.
|
||||
# @return [String]
|
||||
#
|
||||
def inspect(indent = 0)
|
||||
class_name = self.class.to_s.split('::').last
|
||||
spacing = ' ' * indent
|
||||
def inspect
|
||||
segments = []
|
||||
|
||||
return <<-EOF.strip
|
||||
#{class_name}(
|
||||
#{spacing} name: #{name.inspect}
|
||||
#{spacing} type: #{type.inspect}
|
||||
#{spacing} public_id: #{public_id.inspect}
|
||||
#{spacing} system_id: #{system_id.inspect}
|
||||
#{spacing} inline_rules: #{inline_rules.inspect}
|
||||
#{spacing})
|
||||
EOF
|
||||
[:name, :type, :public_id, :system_id, :inline_rules].each do |attr|
|
||||
value = send(attr)
|
||||
|
||||
if value and !value.empty?
|
||||
segments << "#{attr}: #{value.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
return "Doctype(#{segments.join(' ')})"
|
||||
end
|
||||
|
||||
##
|
||||
|
||||
+9
-18
@@ -115,29 +115,20 @@ module Oga
|
||||
# @return [String]
|
||||
#
|
||||
def inspect
|
||||
class_name = self.class.to_s.split('::').last
|
||||
segments = []
|
||||
child_lines = children.map { |child| child.inspect(4) }.join("\n")
|
||||
|
||||
if doctype
|
||||
dtd = doctype.inspect(2)
|
||||
else
|
||||
dtd = doctype.inspect
|
||||
[:doctype, :xml_declaration].each do |attr|
|
||||
value = send(attr)
|
||||
|
||||
if value
|
||||
segments << "#{attr}: #{value.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
if xml_declaration
|
||||
decl = xml_declaration.inspect(2)
|
||||
else
|
||||
decl = xml_declaration.inspect
|
||||
end
|
||||
segments << "children: [\n#{child_lines}\n]"
|
||||
|
||||
return <<-EOF.strip
|
||||
#{class_name}(
|
||||
doctype: #{dtd}
|
||||
xml_declaration: #{decl}
|
||||
children: [
|
||||
#{child_lines}
|
||||
])
|
||||
EOF
|
||||
return "Document(\n #{segments.join("\n ")})"
|
||||
end
|
||||
end # Document
|
||||
end # XML
|
||||
|
||||
+11
-3
@@ -114,11 +114,19 @@ module Oga
|
||||
child_lines = children.map { |child| child.inspect(indent + 4) }
|
||||
.join("\n")
|
||||
|
||||
segments = []
|
||||
|
||||
[:name, :namespace, :attributes].each do |attr|
|
||||
value = send(attr)
|
||||
|
||||
if value and !value.empty?
|
||||
segments << "#{attr}: #{value.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
return <<-EOF.chomp
|
||||
|
||||
#{spacing} name: #{name.inspect}
|
||||
#{spacing} namespace: #{namespace.inspect}
|
||||
#{spacing} attributes: #{attributes.inspect}
|
||||
#{spacing} #{segments.join("\n#{spacing} ")}
|
||||
#{spacing} children: [
|
||||
#{child_lines}
|
||||
#{spacing}]
|
||||
|
||||
@@ -49,20 +49,20 @@ module Oga
|
||||
end
|
||||
|
||||
##
|
||||
# @param [Fixnum] indent
|
||||
# @return [String]
|
||||
#
|
||||
def inspect(indent = 0)
|
||||
class_name = self.class.to_s.split('::').last
|
||||
spacing = ' ' * indent
|
||||
def inspect
|
||||
segments = []
|
||||
|
||||
return <<-EOF.strip
|
||||
#{class_name}(
|
||||
#{spacing} version: #{version.inspect}
|
||||
#{spacing} encoding: #{encoding.inspect}
|
||||
#{spacing} standalone: #{standalone.inspect}
|
||||
#{spacing})
|
||||
EOF
|
||||
[:version, :encoding, :standalone].each do |attr|
|
||||
value = send(attr)
|
||||
|
||||
if value and !value.empty?
|
||||
segments << "#{attr}: #{value.inspect}"
|
||||
end
|
||||
end
|
||||
|
||||
return "XmlDeclaration(#{segments.join(' ')})"
|
||||
end
|
||||
|
||||
##
|
||||
|
||||
Reference in new issue
Block a user