Class: RegexpExamples::MultiGroup
- Inherits:
-
Object
- Object
- RegexpExamples::MultiGroup
- Defined in:
- lib/regexp-examples/groups.rb
Instance Attribute Summary collapse
-
#group_id ⇒ Object
readonly
Returns the value of attribute group_id.
Instance Method Summary collapse
-
#initialize(groups, group_id) ⇒ MultiGroup
constructor
A new instance of MultiGroup.
-
#result ⇒ Object
Generates the result of each contained group and adds the filled group of each result to itself.
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_id ⇒ Object (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
#result ⇒ Object
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 |