lib/regexp-examples/repeaters.rb in regexp-examples-1.1.4 vs lib/regexp-examples/repeaters.rb in regexp-examples-1.2.0

- old
+ new

@@ -10,17 +10,19 @@ end def result group_results = group.result.first(RegexpExamples.max_group_results) results = [] + max_results_limiter = MaxResultsLimiterBySum.new min_repeats.upto(max_repeats) do |repeats| - if repeats.zero? - results << [GroupResult.new('')] - else - results << RegexpExamples.permutations_of_strings( - [group_results] * repeats - ) - end + result = if repeats.zero? + [GroupResult.new('')] + else + RegexpExamples.permutations_of_strings( + [group_results] * repeats + ) + end + results << max_results_limiter.limit_results(result) end results.flatten.uniq end def random_result