Module: MachineGun::Bridge
- Extended by:
- FFI::Library
- Defined in:
- lib/machine-gun/bridge.rb
Class Method Summary collapse
Class Method Details
.command(cmd, in_hash) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/machine-gun/bridge.rb', line 12 def self.command(cmd, in_hash) input = JSON.generate(in_hash) rescue nil out_ptr = FFI::MemoryPointer.new(:pointer, 1) BridgeCommand(cmd, input, out_ptr) out_json = out_ptr.read_pointer.read_string.force_encoding('UTF-8') Free(out_ptr.read_pointer) result = JSON.load(out_json) if result && result["error"] raise Error.new(result["code"], result["error"]) end result end |