lib/regexp-examples/groups.rb in regexp-examples-0.0.1 vs lib/regexp-examples/groups.rb in regexp-examples-0.0.2
- old
+ new
@@ -91,16 +91,21 @@
end
end
class OrGroup
def initialize(left_repeaters, right_repeaters)
- @repeaters = left_repeaters.concat(right_repeaters)
+ @left_repeaters = left_repeaters
+ @right_repeaters = right_repeaters
end
def result
- @repeaters.map do |repeater|
- RegexpExamples::permutations_of_strings(repeater.result)
+ left_result = @left_repeaters.map do |repeater|
+ RegexpExamples::permutations_of_strings([repeater.result])
end
+ right_result = @right_repeaters.map do |repeater|
+ RegexpExamples::permutations_of_strings([repeater.result])
+ end
+ left_result.concat(right_result).flatten.uniq
end
end
class BackReferenceGroup
attr_reader :num