lib/csl/node.rb in csl-1.1.0 vs lib/csl/node.rb in csl-1.2.0
- old
+ new
@@ -1,10 +1,11 @@
module CSL
class Node
extend Forwardable
+ extend Extensions::Nesting
include Enumerable
include Comparable
include Treelike
@@ -231,11 +232,11 @@
yield self if block_given?
end
def initialize_copy(other)
- super
+ @parent, @ancestors, @descendants, @siblings, @root, @depth = nil
initialize(other.attributes)
end
def deep_copy
copy = dup
@@ -429,11 +430,11 @@
Hash[map { |name, value|
!value.nil? && filter.include?(name) ? [name, value.to_s] : nil
}.compact]
end
-
+
# @return [Hash] the node's formatting options
def formatting_options
options = attributes_for Schema.attr(:formatting)
if !root? && parent.respond_to?(:inheritable_formatting_options)
@@ -565,18 +566,23 @@
# end
# end
def initialize(argument = '')
case
- when argument.is_a?(Hash)
+ when argument.respond_to?(:each_pair)
super
when argument.respond_to?(:to_s)
super({})
@text = argument.to_s
yield self if block_given?
else
raise ArgumentError, "failed to create text node from #{argument.inspect}"
end
+ end
+
+ def initialize_copy(other)
+ super
+ @text = other.text
end
def textnode?
true
end