lib/regexp-examples/groups.rb in regexp-examples-0.1.0 vs lib/regexp-examples/groups.rb in regexp-examples-0.2.0
- old
+ new
@@ -76,11 +76,11 @@
# Generates the result of each contained group
# and adds the filled group of each result to
# itself
def result
strings = @groups.map {|repeater| repeater.result}
- subgroups = @groups.select{ |repeater| repeater.group.respond_to? :group_id}.map{|repeater| repeater.group}
RegexpExamples::permutations_of_strings(strings).map do |result|
+ subgroups = result.respond_to?(:group_id) ? result.all_subgroups : []
group_id ? CaptureGroupResult.new(group_id, subgroups, result) : result
end
end
end