lib/csl/treelike.rb in csl-1.5.0 vs lib/csl/treelike.rb in csl-1.5.1

- old
+ new

@@ -15,13 +15,13 @@ # @return [String] the node's name. def nodename @nodename ||= self.class.name.split(/::/)[-1].gsub(/([[:lower:]])([[:upper:]])/, '\1-\2').downcase end - def each_child + def each_child(&block) if block_given? - children.each(&Proc.new) + children.each(&block) self else enum_for :each_child end end @@ -165,15 +165,15 @@ def siblings @siblings = each_sibling.to_a end # Traverses the node's sub-tree in depth-first order. - def each_descendant + def each_descendant(&block) if block_given? each_child do |child| yield child - child.each_descendant(&Proc.new) + child.each_descendant(&block) end self else enum_for :each_descendant @@ -374,12 +374,12 @@ alias original_each each # Iterates through all children. Nil values are skipped and Arrays # expanded. - def each + def each(&block) if block_given? - order.each(&Proc.new) + order.each(&block) self else to_enum end end