This mapping has 3 multi-map groups: several pairings are equally correct there. The code view shows one arbitrary valid pairing, not the only one.

Before

1unless Enumerator.method_defined? :product
2 if RUBY_VERSION >= '2.7'
3 instance_eval <<-'EOT', __FILE__, __LINE__ + 1
4 def Enumerator.product(*enums, **kwargs, &block)
5 if kwargs && !kwargs.empty?
6 raise ArgumentError, "unknown keywords: #{kwargs.keys.map(&:inspect).join(', ')}"
7 end
8 Enumerator::Product.new(*enums).each(&block)
9 end
10 EOT
11 else
12 def Enumerator.product(*enums, &block)
13 kwargs = enums[-1]
14 if kwargs.is_a?(Hash) && !kwargs.empty?
15 raise ArgumentError, "unknown keywords: #{kwargs.keys.map(&:inspect).join(', ')}"
16 end
17 Enumerator::Product.new(*enums).each(&block)
18 end
19 end
20
21 class Enumerator::Product < Enumerator
22 if RUBY_VERSION >= '2.7'
23 module_eval <<-EOT, __FILE__, __LINE__ + 1
24 def initialize(*enums, **nil)
25 @__enums = enums
26 end
27 EOT
28 else
29 # rubocop:disable Lint/MissingSuper
30 def initialize(*enums)
31 @__enums = enums
32 end
33 # rubocop:enable Lint/MissingSuper
34 end
35
36 def each(&block)
37 return self unless block
38 __execute(block, [], @__enums)
39 end
40
41 def __execute(block, values, enums)
42 if enums.empty?
43 block.yield values
44 else
45 enum, *enums = enums
…lines 46–52 unchanged (7 lines)
53
54 def size
55 total_size = 1
56 @__enums.each do |enum|
57 return nil unless enum.respond_to?(:size)
58 size = enum.size
59 return size if size == nil || size == Float::INFINITY || size == 0
60 return nil unless size.is_a?(Integer)
61 total_size *= size
62 end
63 total_size
64 end
65
66 def rewind
67 @__enums.each do |enum|
68 enum.rewind if enum.respond_to?(:rewind)
69 end
70 self
71 end
72 end
73end
74

After

1unless Enumerator.method_defined? :product
2 if RUBY_VERSION >= '2.7'
3 instance_eval <<-'EOT', __FILE__, __LINE__ + 1
4 def Enumerator.product(*enums, **kwargs, &block)
5 if kwargs && !kwargs.empty?
6 raise ArgumentError, "unknown keywords: #{kwargs.keys.map(&:inspect).join(', ')}"
7 end
8 product = Enumerator::Product.new(*enums)
9
10 if block_given?
11 product.each(&block)
12 return nil
13 end
14
15 product
16 end
17 EOT
18 else
19 def Enumerator.product(*enums, &block)
20 kwargs = enums[-1]
21 if kwargs.is_a?(Hash) && !kwargs.empty?
22 raise ArgumentError, "unknown keywords: #{kwargs.keys.map(&:inspect).join(', ')}"
23 end
24 product = Enumerator::Product.new(*enums)
25
26 if block_given?
27 product.each(&block)
28 return nil
29 end
30
31 product
32 end
33 end
34
35 class Enumerator::Product < Enumerator
36 if RUBY_VERSION >= '2.7'
37 module_eval <<-EOT, __FILE__, __LINE__ + 1
38 def initialize(*enums, **nil)
39 @__enums = enums
40 end
41 EOT
42 else
43 # rubocop:disable Lint/MissingSuper
44 def initialize(*enums)
45 @__enums = enums
46 self
47 end
48 # rubocop:enable Lint/MissingSuper
49 end
50
51 def each(&block)
52 return self unless block
53 __execute(block, [], @__enums)
54 self
55 end
56
57 def __execute(block, values, enums)
58 if enums.empty?
59 block.yield values
60 else
…lines 61–68 unchanged (8 lines)
69
70 def size
71 total_size = 1
72 @__enums.each do |enum|
73 return nil unless enum.respond_to?(:size)
74 size = enum.size
75 return size if size == 0 || size == nil || size == Float::INFINITY || size == -Float::INFINITY
76 return nil unless size.is_a?(Integer)
77 total_size *= size
78 end
79 total_size
80 end
81
82 def rewind
83 @__enums.each do |enum|
84 enum.rewind if enum.respond_to?(:rewind)
85 end
86 self
87 end
88
89 private def initialize_copy(other)
90 return self if self.equal?(other)
91
92 raise TypeError if !(Product === other)
93
94 super(other)
95
96 other_enums = other.instance_variable_get(:@__enums)
97
98 raise ArgumentError.new("uninitialized product") unless other_enums
99
100 @__enums = other_enums
101
102 self
103 end
104 end
105end
106

Before

program
unless
unless "unless"
call
constant "Enumerator"
. "."
identifier "method_defined?"
argument_list
simple_symbol ":product"
then
if
if "if"
binary
constant "RUBY_VERSION"
>= ">="
string
" "'"
string_content "2.7"
" "'"
then
call
identifier "instance_eval"
argument_list
heredoc_beginning "<<-'EOT'"
, ","
identifier "__FILE__"
, ","
binary
identifier "__LINE__"
+ "+"
integer "1"
heredoc_body
heredoc_content "\n def Enumerator.product(*enums, **kwargs, &block)\n "...
heredoc_end "EOT"
else
else "else"
singleton_method
def "def"
constant "Enumerator"
. "."
identifier "product"
method_parameters
( "("
splat_parameter
* "*"
identifier "enums"
, ","
block_parameter
& "&"
identifier "block"
) ")"
body_statement
assignment
identifier "kwargs"
= "="
element_reference
identifier "enums"
[ "["
unary
- "-"
integer "1"
] "]"
if (+55 nodes collapsed)
call any 1:2
call
scope_resolution
constant "Enumerator"
:: "::"
constant "Product"
. "."
identifier "new"
argument_list
( "("
splat_argument
* "*"
identifier "enums"
) ")"
. "."
identifier "each"
argument_list
( "("
block_argument
& "&"
identifier "block"
) ")"
end "end"
end "end"
class
class "class"
scope_resolution
constant "Enumerator"
:: "::"
constant "Product"
superclass
< "<"
constant "Enumerator"
body_statement
if
if "if"
binary
constant "RUBY_VERSION"
>= ">="
string
" "'"
string_content "2.7"
" "'"
then
call
identifier "module_eval"
argument_list
heredoc_beginning "<<-EOT"
, ","
identifier "__FILE__"
, ","
binary
identifier "__LINE__"
+ "+"
integer "1"
heredoc_body
heredoc_content "\n def initialize(*enums, **nil)\n @__enums = "...
heredoc_end "EOT"
else
else "else"
comment "# rubocop:disable Lint/MissingSuper"
method
def "def"
identifier "initialize"
method_parameters
( "("
splat_parameter
* "*"
identifier "enums"
) ")"
body_statement
assignment
instance_variable "@__enums"
= "="
identifier "enums"
end "end"
comment "# rubocop:enable Lint/MissingSuper"
end "end"
method
def "def"
identifier "each"
method_parameters
( "("
block_parameter
& "&"
identifier "block"
) ")"
body_statement
unless_modifier
return
return "return"
argument_list
self "self"
unless "unless"
identifier "block"
call
identifier "__execute"
argument_list
( "("
identifier "block"
, ","
array
[ "["
] "]"
, ","
instance_variable "@__enums"
) ")"
end "end"
method (+69 nodes collapsed)
call
identifier "private"
argument_list
simple_symbol ":__execute"
method
def "def"
identifier "size"
body_statement
assignment
identifier "total_size"
= "="
integer "1"
call
instance_variable "@__enums"
. "."
identifier "each"
do_block
do "do"
block_parameters
| "|"
identifier "enum"
| "|"
body_statement
unless_modifier
return
return "return"
argument_list
nil
nil "nil"
unless "unless"
call
identifier "enum"
. "."
identifier "respond_to?"
argument_list
( "("
simple_symbol ":size"
) ")"
assignment
identifier "size"
= "="
call
identifier "enum"
. "."
identifier "size"
if_modifier
return
return "return"
argument_list
identifier "size"
if "if"
binary any 2:3
binary any 2:3
binary
identifier "size"
== "=="
nil
nil "nil"
|| "||" any 2:3
binary
identifier "size"
== "=="
scope_resolution
constant "Float"
:: "::"
constant "INFINITY"
|| "||" any 2:3
binary
identifier "size"
== "=="
integer "0"
unless_modifier
return
return "return"
argument_list
nil
nil "nil"
unless "unless"
call
identifier "size"
. "."
identifier "is_a?"
argument_list
( "("
constant "Integer"
) ")"
operator_assignment
identifier "total_size"
*= "*="
identifier "size"
end "end"
identifier "total_size"
end "end"
method (+32 nodes collapsed)
end "end"
end "end"

After

program
unless
unless "unless"
call
constant "Enumerator"
. "."
identifier "method_defined?"
argument_list
simple_symbol ":product"
then
if
if "if"
binary
constant "RUBY_VERSION"
>= ">="
string
" "'"
string_content "2.7"
" "'"
then
call
identifier "instance_eval"
argument_list
heredoc_beginning "<<-'EOT'"
, ","
identifier "__FILE__"
, ","
binary
identifier "__LINE__"
+ "+"
integer "1"
heredoc_body
heredoc_content "\n def Enumerator.product(*enums, **kwargs, &block)\n "...
heredoc_end "EOT"
else
else "else"
singleton_method
def "def"
constant "Enumerator"
. "."
identifier "product"
method_parameters
( "("
splat_parameter
* "*"
identifier "enums"
, ","
block_parameter
& "&"
identifier "block"
) ")"
body_statement
assignment
identifier "kwargs"
= "="
element_reference
identifier "enums"
[ "["
unary
- "-"
integer "1"
] "]"
if (+55 nodes collapsed)
assignment
identifier "product"
= "="
call
scope_resolution
constant "Enumerator"
:: "::"
constant "Product"
. "."
identifier "new"
argument_list
( "("
splat_argument
* "*"
identifier "enums"
) ")"
if
if "if"
call any 1:2
identifier "block_given?"
then
call any 1:2
identifier "product"
. "."
identifier "each"
argument_list
( "("
block_argument
& "&"
identifier "block"
) ")"
return
return "return"
argument_list
nil
nil "nil"
end "end"
identifier "product"
end "end"
end "end"
class
class "class"
scope_resolution
constant "Enumerator"
:: "::"
constant "Product"
superclass
< "<"
constant "Enumerator"
body_statement
if
if "if"
binary
constant "RUBY_VERSION"
>= ">="
string
" "'"
string_content "2.7"
" "'"
then
call
identifier "module_eval"
argument_list
heredoc_beginning "<<-EOT"
, ","
identifier "__FILE__"
, ","
binary
identifier "__LINE__"
+ "+"
integer "1"
heredoc_body
heredoc_content "\n def initialize(*enums, **nil)\n @__enums = "...
heredoc_end "EOT"
else
else "else"
comment "# rubocop:disable Lint/MissingSuper"
method
def "def"
identifier "initialize"
method_parameters
( "("
splat_parameter
* "*"
identifier "enums"
) ")"
body_statement
assignment
instance_variable "@__enums"
= "="
identifier "enums"
self "self"
end "end"
comment "# rubocop:enable Lint/MissingSuper"
end "end"
method
def "def"
identifier "each"
method_parameters
( "("
block_parameter
& "&"
identifier "block"
) ")"
body_statement
unless_modifier
return
return "return"
argument_list
self "self"
unless "unless"
identifier "block"
call
identifier "__execute"
argument_list
( "("
identifier "block"
, ","
array
[ "["
] "]"
, ","
instance_variable "@__enums"
) ")"
self "self"
end "end"
method (+69 nodes collapsed)
call
identifier "private"
argument_list
simple_symbol ":__execute"
method
def "def"
identifier "size"
body_statement
assignment
identifier "total_size"
= "="
integer "1"
call
instance_variable "@__enums"
. "."
identifier "each"
do_block
do "do"
block_parameters
| "|"
identifier "enum"
| "|"
body_statement
unless_modifier
return
return "return"
argument_list
nil
nil "nil"
unless "unless"
call
identifier "enum"
. "."
identifier "respond_to?"
argument_list
( "("
simple_symbol ":size"
) ")"
assignment
identifier "size"
= "="
call
identifier "enum"
. "."
identifier "size"
if_modifier
return
return "return"
argument_list
identifier "size"
if "if"
binary any 2:3
binary any 2:3
binary any 2:3
binary
identifier "size"
== "=="
integer "0"
|| "||" any 2:3
binary
identifier "size"
== "=="
nil
nil "nil"
|| "||" any 2:3
binary
identifier "size"
== "=="
scope_resolution
constant "Float"
:: "::"
constant "INFINITY"
|| "||" any 2:3
binary
identifier "size"
== "=="
unary
- "-"
scope_resolution
constant "Float"
:: "::"
constant "INFINITY"
unless_modifier
return
return "return"
argument_list
nil
nil "nil"
unless "unless"
call
identifier "size"
. "."
identifier "is_a?"
argument_list
( "("
constant "Integer"
) ")"
operator_assignment
identifier "total_size"
*= "*="
identifier "size"
end "end"
identifier "total_size"
end "end"
method (+32 nodes collapsed)
call
identifier "private"
argument_list
method
def "def"
identifier "initialize_copy"
method_parameters
( "("
identifier "other"
) ")"
body_statement
if_modifier
return
return "return"
argument_list
self "self"
if "if"
call
self "self"
. "."
identifier "equal?"
argument_list
( "("
identifier "other"
) ")"
if_modifier
call
identifier "raise"
argument_list
constant "TypeError"
if "if"
unary
! "!"
parenthesized_statements
( "("
binary
constant "Product"
=== "==="
identifier "other"
) ")"
call
super "super"
argument_list
( "("
identifier "other"
) ")"
assignment
identifier "other_enums"
= "="
call
identifier "other"
. "."
identifier "instance_variable_get"
argument_list
( "("
simple_symbol ":@__enums"
) ")"
unless_modifier
call
identifier "raise"
argument_list
call
constant "ArgumentError"
. "."
identifier "new"
argument_list
( "("
string
" "\""
string_content "uninitialized product"
" "\""
) ")"
unless "unless"
identifier "other_enums"
assignment
instance_variable "@__enums"
= "="
identifier "other_enums"
self "self"
end "end"
end "end"
end "end"