class RegexpExamples::MultiGroup

A collection of other groups. Basically any regex that contains brackets will be parsed using one of these. The simplest example is: /(a)/ - Which is a MultiGroup, containing one SingleCharGroup

Attributes

group_id[R]

Public Class Methods

new(groups, group_id) click to toggle source
# File lib/regexp-examples/groups.rb, line 120
def initialize(groups, group_id)
  @groups = groups
  @group_id = group_id
end

Public Instance Methods

random_result()
Alias for: result
result() click to toggle source

Generates the result of each contained group and adds the filled group of each result to itself

# File lib/regexp-examples/groups.rb, line 127
def result
  strings = @groups.map { |repeater| repeater.public_send(__callee__) }
  RegexpExamples.permutations_of_strings(strings).map do |result|
    GroupResult.new(result, group_id)
  end
end
Also aliased as: random_result