Class: LivecodeServer::Daemon
- Inherits:
-
Object
- Object
- LivecodeServer::Daemon
- Defined in:
- lib/livecode_server/daemon.rb
Instance Attribute Summary collapse
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#initialize(scope = nil) ⇒ Daemon
constructor
A new instance of Daemon.
- #output(string, prefix = nil) ⇒ Object
- #run(code) ⇒ Object
Constructor Details
Instance Attribute Details
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
3 4 5 |
# File 'lib/livecode_server/daemon.rb', line 3 def scope @scope end |
Instance Method Details
#output(string, prefix = nil) ⇒ Object
10 11 12 13 14 |
# File 'lib/livecode_server/daemon.rb', line 10 def output(string, prefix=nil) @output += string + "\n" puts (prefix) ? "#{prefix} #{string}" : string return nil end |
#run(code) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/livecode_server/daemon.rb', line 16 def run(code) code = code.strip @output = "" puts begin puts "--- #{Time.now}:" puts ">> #{code}" result = eval(code, @scope.get_binding) puts "=> #{result}" rescue Exception => e output "#{e.class}: #{e}", "!!" end return @output end |