Class: Scripted::Commands::Ruby

Inherits:
Object
  • Object
show all
Defined in:
lib/scripted/commands/ruby.rb

Instance Method Summary collapse

Constructor Details

#initialize(code) ⇒ Ruby

Returns a new instance of Ruby.



5
6
7
# File 'lib/scripted/commands/ruby.rb', line 5

def initialize(code)
  @code = code
end

Instance Method Details

#execute!(log = STDOUT) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/scripted/commands/ruby.rb', line 9

def execute!(log = STDOUT)
  old_stdout = $stdout
  old_stderr = $stderr
  $stdout = log
  $stderr = log
  @code.call
ensure
  $stdout = old_stdout
  $stderr = old_stderr
end