class CZMQ::FFI::ZhttpClient
Http client, allowing multiple requests simultaneously and integrate easily with zpoller. Use zhttp_request class to create and send the request. Use zhttp_response class to receive the response. @note This class is 100% generated using zproject.
Public Class Methods
@param ptr [::FFI::Pointer] @return [Proc]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 37 def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zhttp_client_destroy ptr_ptr end end
Attaches the pointer ptr to this instance and defines a finalizer for it if necessary. @param ptr [::FFI::Pointer] @param finalize [Boolean]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 26 def initialize(ptr, finalize = true) @ptr = ptr if @ptr.null? @ptr = nil # Remove null pointers so we don't have to test for them. elsif finalize @finalizer = self.class.create_finalizer_for @ptr ObjectSpace.define_finalizer self, @finalizer end end
Create a new http client @param verbose [Boolean] @return [CZMQ::ZhttpClient]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 81 def self.new(verbose) verbose = !(0==verbose||!verbose) # boolean ptr = ::CZMQ::FFI.zhttp_client_new(verbose) __new ptr end
Self test of this class.
@param verbose [Boolean] @return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 101 def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zhttp_client_test(verbose) result end
Public Instance Methods
Return internal pointer @return [::FFI::Pointer]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 50 def __ptr raise DestroyedError unless @ptr @ptr end
Nullify internal pointer and return pointer pointer. @note This detaches the current instance from the native object
and thus makes it unusable.
@return [::FFI::MemoryPointer] the pointer pointing to a pointer
pointing to the native object
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 61 def __ptr_give_ref raise DestroyedError unless @ptr ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer @ptr __undef_finalizer if @finalizer @ptr = nil ptr_ptr end
Undefines the finalizer for this object. @note Only use this if you need to and can guarantee that the native
object will be freed by other means.
@return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 73 def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end
Destroy an http client
@return [void]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 90 def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zhttp_client_destroy(self_p) result end
@return [Boolean]
# File lib/czmq-ffi-gen/czmq/ffi/zhttp_client.rb, line 45 def null? !@ptr or @ptr.null? end