Class: Michelle::Server
- Inherits:
-
Object
- Object
- Michelle::Server
- Defined in:
- lib/michelle/server.rb
Instance Method Summary collapse
Instance Method Details
#redirect ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/michelle/server.rb', line 10 def redirect orig_stdout = $stdout orig_stderr = $stderr $stdout = StringIO.new $stderr = StringIO.new yield $stdout.string + $stderr.string ensure $stdout = orig_stdout $stderr = orig_stderr end |
#to_eval(code) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/michelle/server.rb', line 22 def to_eval code redirect do begin @last_return = eval code rescue SyntaxError => puts end end end |