Class: RegexpExamples::MultiGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/regexp-examples/groups.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(groups, group_id) ⇒ MultiGroup

Returns a new instance of MultiGroup.



107
108
109
110
# File 'lib/regexp-examples/groups.rb', line 107

def initialize(groups, group_id)
  @groups = groups
  @group_id = group_id
end

Instance Attribute Details

#group_idObject (readonly)

Returns the value of attribute group_id.



106
107
108
# File 'lib/regexp-examples/groups.rb', line 106

def group_id
  @group_id
end

Instance Method Details

#resultObject

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



115
116
117
118
119
120
# File 'lib/regexp-examples/groups.rb', line 115

def result
  strings = @groups.map {|repeater| repeater.result}
  RegexpExamples.permutations_of_strings(strings).map do |result|
    GroupResult.new(result, group_id)
  end
end