I wonder why this yielder.yield will leave the loop temporarily and also return the value of number until the next enumerator object created. It seems different than the usual case when a yield inside the loop block. I check the APIdock and find that the source code of Proc.yield() is the same as Proc.call(). For the Yielder object in the Enumerator class, the Yielder has override the yield(). But why the yielder.yield will temporarily leave the loop block?

You are confusing Ruby's yield statement with Enumerator::Yielder's yield method and Proc's yield method. They may be spelled the same but they are completely different.

Statement

The yield statement has no receiver. Inside a method it means "Run the block right now". An error occurs if no block is attached. It is not always given an argument, because sometimes you just want to run the block.

def foo
yield :bar
end
foo # LocalJumpError
foo { |x| puts x } # bar

Enumerator::Yielder

For a yielder, yield is almost always given an argument. That's because it means the same as << which is "The next time someone calls next on me, give them this value".

I think it's a good idea to use << to avoid confusion with the yield statement.

Proc

Procs and lambdas are basically functions. yield here means the same thing as call, which "Just call the function". You can give it an argument or not, depending on how the proc was defined. Nothing fancy here.