These are two nested loops, and folding becomes incorrect, when those 'puts' commands are added in the outer loop.
Folding the inner loop hides all 'puts' as well, but they are not part of the inner loop, they are in the outer 'do' - 'end' block.
for j in 0...SIZE do
for i in 0...SIZE do
printf("%3d ", array[j][i])
I didn't test other loop constructs, but Ruby has a metric tons of them, others might be incorrect as well.