Class: Esolang::Interpreters::Ook
- Inherits:
-
Brainfuck
- Object
- BaseInterpreter
- Brainfuck
- Esolang::Interpreters::Ook
- Defined in:
- lib/interpreters/ook_interpreter.rb
Overview
The Ook class represents an interpreter for the Ook! esoteric programming language, which is translated to Brainfuck for execution.
Instance Method Summary collapse
-
#initialize(code, input = '') ⇒ Ook
constructor
Initializes a new instance of the Ook interpreter.
-
#run ⇒ String
Executes the interpretation of the Ook code.
Constructor Details
#initialize(code, input = '') ⇒ Ook
Initializes a new instance of the Ook interpreter.
14 15 16 17 |
# File 'lib/interpreters/ook_interpreter.rb', line 14 def initialize(code, input = '') super(translate_to_brainfuck(code), input) @input = input end |
Instance Method Details
#run ⇒ String
Executes the interpretation of the Ook code.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/interpreters/ook_interpreter.rb', line 22 def run while running? do case command when ',' then input_to_tape when '.' then tape_to_output_array when '>' then move_right when '<' then move_left when '+' then increment when '-' then decrement when '[' then loop_begin when ']' then loop_end when '?' then banana end @code_pointer += 1 end translate_output_bytes_to_chars end |