Document should not inherit from Node.

A document is not an XML node on itself. If logic has to be shared between the
Document and the Node class I'll resort to using mixins for this.
This commit is contained in:
Yorick Peterse 2014-04-03 22:45:40 +02:00
parent c077988dd6
commit 230fafa2d3
1 changed files with 13 additions and 2 deletions

View File

@ -3,8 +3,19 @@ module Oga
##
# Class description
#
class Document < Node
attr_accessor :doctype, :xml_declaration
class Document
attr_accessor :children, :doctype, :xml_declaration
##
# @param [Hash] options
#
def initialize(options = {})
options.each do |key, value|
instance_variable_set("@#{key}", value) if respond_to?(key)
end
@children ||= []
end
def to_xml
xml = children.map(&:to_xml).join('')