lib/rambling/trie/compressor.rb in rambling-trie-0.6.1 vs lib/rambling/trie/compressor.rb in rambling-trie-0.7.0
- old
+ new
@@ -25,23 +25,21 @@
def compressable?
!(root? || terminal?) && children_tree.size == 1
end
- def merge_with!(child)
+ def merge_with! child
delete_old_key_on_parent!
redefine_self! child
children.each { |node| node.parent = self }
end
def delete_old_key_on_parent!
- return if parent.nil?
-
- parent.delete letter
+ parent.delete letter if parent
end
- def redefine_self!(merged_node)
+ def redefine_self! merged_node
self.letter = letter.to_s << merged_node.letter.to_s
self.children_tree = merged_node.children_tree
self.terminal = merged_node.terminal?
end
end