Class: BefungeInterpreterDebugger
- Inherits:
-
BefungeInterpreter
- Object
- BefungeInterpreter
- BefungeInterpreterDebugger
- Defined in:
- lib/befunge_interpreter.rb
Overview
Use this class for debugger mode
Constant Summary
Constants included from Operations
Operations::DIRECTIONS, Operations::DIRECTIONS_MAP, Operations::DIRECTION_OPS, Operations::MATH_OPS, Operations::OPERATORS, Operations::OPERATORS_MAP
Instance Method Summary collapse
Methods inherited from BefungeInterpreter
Methods included from Operations
#change_dir, #duplicate_stack_top, #end_program, #get_call, #get_user_input_char, #get_user_input_int, #greater_than, #left_right, #logical_not, #operate!, #pop_and_discard, #pop_and_display_char, #pop_and_display_int, #push_ascii_value, #push_num, #put_call, #rand_direction, #string_mode, #swap_stack_top, #trampoline, #up_down
Constructor Details
This class inherits a constructor from BefungeInterpreter
Instance Method Details
#interpret ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/befunge_interpreter.rb', line 58 def interpret print_status while @computing puts "\nDebugger Mode!~" puts 'Commands: n = next([, step_amt]), p = put_operation(x, y, op)' user_input = $stdin.gets.chomp case user_input when /\An\z/ then operate_and_step when /\An \d+\z/ then operate_and_step(Integer(user_input[2..-1])) when /\A(\d+)n/ then operate_and_step(Integer(user_input.match(/(\d+)/)[1])) when /\Aquit\z/ then @computing = false end print_status end end |
#operate_and_step(n = 1) ⇒ Object
74 75 76 |
# File 'lib/befunge_interpreter.rb', line 74 def operate_and_step(n = 1) n.times { super() } end |