lib/regexp-examples/groups.rb in regexp-examples-1.1.4 vs lib/regexp-examples/groups.rb in regexp-examples-1.2.0
- old
+ new
@@ -156,21 +156,23 @@
def initialize(left_repeaters, right_repeaters)
@repeaters_list = [left_repeaters, *merge_if_orgroup(right_repeaters)]
end
def result
- result_by_method(:map_results)
+ result_by_method(:result)
end
def random_result
- result_by_method(:map_random_result).sample(1)
+ result_by_method(:random_result).sample(1)
end
private
def result_by_method(method)
+ max_results_limiter = MaxResultsLimiterBySum.new
repeaters_list
- .map { |repeaters| RegexpExamples.public_send(method, repeaters) }
+ .map { |repeaters| RegexpExamples.generic_map_result(repeaters, method) }
+ .map { |result| max_results_limiter.limit_results(result)}
.inject(:concat)
.map { |result| GroupResult.new(result) }
.uniq
end