Top Level Namespace

Defined Under Namespace

Classes: Goto, Label

Constant Summary collapse

STACK =
[]

Instance Method Summary collapse

Instance Method Details

#frame_endObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/goto.rb', line 30

def frame_end
  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_startObject



26
27
28
# File 'lib/goto.rb', line 26

def frame_start
  STACK << []
end

#goto(label) ⇒ Object

Raises:



44
45
46
# File 'lib/goto.rb', line 44

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

#label(sym, &block) ⇒ Object



22
23
24
# File 'lib/goto.rb', line 22

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