Class: FSEvent::ProcessDevice::Spawner
- Inherits:
-
Object
- Object
- FSEvent::ProcessDevice::Spawner
- Defined in:
- lib/fsevent/processdevice.rb
Instance Method Summary collapse
- #assemble_code(device_name, *args) ⇒ Object
-
#initialize(defs) ⇒ Spawner
constructor
A new instance of Spawner.
- #new(device_name, *args) ⇒ Object
Constructor Details
#initialize(defs) ⇒ Spawner
24 25 26 |
# File 'lib/fsevent/processdevice.rb', line 24 def initialize(defs) @defs = defs end |
Instance Method Details
#assemble_code(device_name, *args) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fsevent/processdevice.rb', line 28 def assemble_code(device_name, *args) code = '' libpath = File.dirname(File.dirname(__FILE__)) code << "$:.unshift #{libpath.dump}\n" code << " require 'fsevent'\n def ep(arg) STDERR.puts arg.inspect end\n End\n\n code << \"class FSEvent::ProcessDevice_\#{device_name} < FSEvent::ProcessDeviceC\\n\#{@defs}\\nend\\n\"\n marshaled_args = Marshal.dump(args)\n code << \"FSEvent::ProcessDeviceC.main(FSEvent::ProcessDevice_\#{device_name}.new(\#{device_name.dump}, *(Marshal.load(\#{marshaled_args.dump}))))\\n\"\nend\n" |
#new(device_name, *args) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/fsevent/processdevice.rb', line 44 def new(device_name, *args) code = assemble_code(device_name, *args) io = IO.popen([RbConfig.ruby], "r+") io.sync = true io.write code io.write "__END__\n" FSEvent::ProcessDevice.send(:new, device_name, io) end |