Permalink
Browse files

fixed bad #remove_nodes behavior with ranges

  • Loading branch information...
chikamichi committed Jul 10, 2011
1 parent a1d7fb5 commit f949f4382126121ee2f2cd762e4c84c51423bc10
Showing with 8 additions and 3 deletions.
  1. +8 −3 lib/jumoku/builders/extended.rb
@@ -163,11 +163,16 @@ def add_branches(*a)
#
# The process relies on {RawTreeBuilder#remove_node! remove_node!}.
#
- # @param [#each] *a an Enumerable nodes set
+ # @param [#each] *nodes an Enumerable nodes set; may contain Range
# @return [Tree] `self`
#
- def remove_nodes!(*a)
- a.flatten.each { |v| remove_node! v }
+ # @example
+ #
+ # remove_nodes! 1, 3..5
+ #
+ def remove_nodes!(*nodes)
+ nodes = nodes.to_a.map { |i| i.is_a?(Range) ? i.to_a : i }.flatten
+ nodes.each { |v| remove_node! v }
self
end
alias delete_nodes! remove_nodes!

0 comments on commit f949f43

Please sign in to comment.