Module: GoTo

Defined in:
lib/rubyhacks.rb

Defined Under Namespace

Classes: Goto, Label

Constant Summary collapse

STACK =
[]

Instance Method Summary collapse

Instance Method Details

#frame_end_gotoObject



945
946
947
948
949
950
951
952
953
954
955
956
957
# File 'lib/rubyhacks.rb', line 945

def frame_end_goto
	frame = STACK.pop
	idx = 0

	begin
		for i in (idx...frame.size)
			frame[i].block.call if frame[i].block
		end
	rescue Goto => g
		idx = frame.index(g.label)
		retry
	end
end

#frame_start_gotoObject



941
942
943
# File 'lib/rubyhacks.rb', line 941

def frame_start_goto
	STACK << []
end

#goto(label) ⇒ Object

Raises:



959
960
961
# File 'lib/rubyhacks.rb', line 959

def goto(label)
	raise Goto.new(label)
end

#label_goto(sym, &block) ⇒ Object



937
938
939
# File 'lib/rubyhacks.rb', line 937

def label_goto(sym, &block)
	STACK.last << Label.new(sym, block)
end