Class: EvalHook::Packet
- Inherits:
-
Object
- Object
- EvalHook::Packet
- Defined in:
- lib/evalhook.rb
Instance Method Summary collapse
-
#initialize(emulationcode) ⇒ Packet
constructor
:nodoc:.
-
#run(binding_, name = "(eval)", line = 1) ⇒ Object
Executes the code with a given binding, source name (optional) and line (optional).
Constructor Details
#initialize(emulationcode) ⇒ Packet
:nodoc:
42 43 44 |
# File 'lib/evalhook.rb', line 42 def initialize(emulationcode) #:nodoc: @emulationcode = emulationcode end |
Instance Method Details
#run(binding_, name = "(eval)", line = 1) ⇒ Object
Executes the code with a given binding, source name (optional) and line (optional)
See EvalHook::HookHandler#packet for more info
Example:
hook_handler = HookHandler.new
pack = hook_handler.packet('print "hello world\n"')
10.times do
pack.run
end
58 59 60 |
# File 'lib/evalhook.rb', line 58 def run(binding_, name = "(eval)", line = 1) eval(@emulationcode, binding_, name, line) end |