Skip to content

Instantly share code, notes, and snippets.

@EmmanuelOga
Created October 12, 2009 19:55
Show Gist options
  • Save EmmanuelOga/208684 to your computer and use it in GitHub Desktop.
Save EmmanuelOga/208684 to your computer and use it in GitHub Desktop.
Programator2000
require 'singleton'
set_trace_func proc { |event, file, line, id, binding, classname|
if event == "line" && file == "Programator2000"
puts Programator2000.instance.to_lines[line - 1]
print "[NEXT]"
gets
end
}
class Programator2000 < Struct.new(:code)
include Singleton
def to_lines
code.split("\n")
end
def to_ruby
code.gsub(/mientras/, "while").gsub(/imprimir/, "puts")
end
def run!
eval(to_ruby, binding, "Programator2000")
end
end
Programator2000.instance.code = <<-CODE
a = 1
mientras a < 5
imprimir a
a = a + 1
end
imprimir "Valor final de a: "
imprimir a
CODE
Programator2000.instance.run!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment