Skip to content

Instantly share code, notes, and snippets.

@z2s8
Created June 6, 2016 23:27
Show Gist options
  • Save z2s8/92f6cd504f4206addb0b16620c1597dd to your computer and use it in GitHub Desktop.
Save z2s8/92f6cd504f4206addb0b16620c1597dd to your computer and use it in GitHub Desktop.
dumb repl in 20 lines of ruby.. todo: wrap exec maybe to crosslang?
#!/usr/bin/env ruby
def save_line(line)
open('repldata', 'a') do |repldata|
repldata.puts "puts %s(> #{line.rstrip})"
repldata.puts "print('= ')"
repldata.puts "puts(#{line})"
end
end
def exec_file
system "clear" or system "cls"
`ruby repldata`
end
loop do
print '> '
save_line gets
puts exec_file
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment