class Basic101::NextStatement

Public Class Methods

new(reference) click to toggle source
# File lib/basic101/next_statement.rb, line 9
def initialize(reference)
  @reference = reference
end

Public Instance Methods

execute(runtime) click to toggle source
# File lib/basic101/next_statement.rb, line 13
def execute(runtime) 
  for_statement = if @reference.nil?
                    runtime.for_stack.top
                  else
                    runtime.for_stack[@reference]
                  end
  raise NextWithoutFor unless for_statement
  for_statement.increment(runtime)
  if for_statement.done?(runtime)
    for_statement.delete_from_stack(runtime)
  else
    for_statement.goto_following_statement(runtime)
  end
end

Protected Instance Methods

state() click to toggle source
# File lib/basic101/next_statement.rb, line 30
def state
  @reference
end