Class: CZMQ::FFI::Zarmour
- Inherits:
-
Object
- Object
- CZMQ::FFI::Zarmour
- Defined in:
- lib/czmq-ffi-gen/czmq/ffi/zarmour.rb
Overview
This class is 100% generated using zproject.
armoured text encoding and decoding
Defined Under Namespace
Classes: DestroyedError
Constant Summary collapse
- MODE_BASE64_STD =
Standard base 64
0- MODE_BASE64_URL =
URL and filename friendly base 64
1- MODE_BASE32_STD =
Standard base 32
2- MODE_BASE32_HEX =
Extended hex base 32
3- MODE_BASE16 =
Standard base 16
4- MODE_Z85 =
Z85 from ZeroMQ RFC 32
5
Class Method Summary collapse
- .__new ⇒ Object
- .create_finalizer_for(ptr) ⇒ Proc
-
.new ⇒ CZMQ::Zarmour
Create a new zarmour.
-
.test(verbose) ⇒ void
Self test of this class.
Instance Method Summary collapse
-
#__ptr ⇒ ::FFI::Pointer
(also: #to_ptr)
Return internal pointer.
-
#__ptr_give_ref ⇒ ::FFI::MemoryPointer
Nullify internal pointer and return pointer pointer.
-
#__undef_finalizer ⇒ void
Undefines the finalizer for this object.
-
#decode(data) ⇒ Zchunk
Decode an armoured string into a chunk.
-
#destroy ⇒ void
Destroy the zarmour.
-
#encode(data, size) ⇒ ::FFI::AutoPointer
Encode a stream of bytes into an armoured string.
-
#initialize(ptr, finalize = true) ⇒ Zarmour
constructor
Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.
-
#line_breaks ⇒ Boolean
Return if splitting output into lines is turned on.
-
#line_length ⇒ Integer
Get the line length used for splitting lines.
-
#mode ⇒ Integer
Get the mode property.
-
#mode_str ⇒ String
Get printable string for mode.
- #null? ⇒ Boolean
-
#pad ⇒ Boolean
Return true if padding is turned on.
-
#pad_char ⇒ ::FFI::Pointer
Get the padding character.
-
#print ⇒ void
Print properties of object.
-
#set_line_breaks(line_breaks) ⇒ void
Turn splitting output into lines on or off.
-
#set_line_length(line_length) ⇒ void
Set the line length used for splitting lines.
-
#set_mode(mode) ⇒ void
Set the mode property.
-
#set_pad(pad) ⇒ void
Turn padding on or off.
-
#set_pad_char(pad_char) ⇒ void
Set the padding character.
Constructor Details
#initialize(ptr, finalize = true) ⇒ Zarmour
Attaches the pointer ptr to this instance and defines a finalizer for it if necessary.
42 43 44 45 46 47 48 49 50 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 42 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 |
Class Method Details
.__new ⇒ Object
36 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 36 alias :__new :new |
.create_finalizer_for(ptr) ⇒ Proc
53 54 55 56 57 58 59 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 53 def self.create_finalizer_for(ptr) Proc.new do ptr_ptr = ::FFI::MemoryPointer.new :pointer ptr_ptr.write_pointer ptr ::CZMQ::FFI.zarmour_destroy ptr_ptr end end |
.new ⇒ CZMQ::Zarmour
Create a new zarmour
96 97 98 99 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 96 def self.new() ptr = ::CZMQ::FFI.zarmour_new() __new ptr end |
.test(verbose) ⇒ void
This method returns an undefined value.
Self test of this class.
274 275 276 277 278 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 274 def self.test(verbose) verbose = !(0==verbose||!verbose) # boolean result = ::CZMQ::FFI.zarmour_test(verbose) result end |
Instance Method Details
#__ptr ⇒ ::FFI::Pointer Also known as: to_ptr
Return internal pointer
66 67 68 69 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 66 def __ptr raise DestroyedError unless @ptr @ptr end |
#__ptr_give_ref ⇒ ::FFI::MemoryPointer
This detaches the current instance from the native object and thus makes it unusable.
Nullify internal pointer and return pointer pointer.
77 78 79 80 81 82 83 84 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 77 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 |
#__undef_finalizer ⇒ void
Only use this if you need to and can guarantee that the native object will be freed by other means.
This method returns an undefined value.
Undefines the finalizer for this object.
89 90 91 92 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 89 def __undef_finalizer ObjectSpace.undefine_finalizer self @finalizer = nil end |
#decode(data) ⇒ Zchunk
Decode an armoured string into a chunk. The decoded output is null-terminated, so it may be treated as a string, if that’s what it was prior to encoding.
133 134 135 136 137 138 139 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 133 def decode(data) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_decode(self_p, data) result = Zchunk.__new result, true result end |
#destroy ⇒ void
This method returns an undefined value.
Destroy the zarmour
104 105 106 107 108 109 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 104 def destroy() return unless @ptr self_p = __ptr_give_ref result = ::CZMQ::FFI.zarmour_destroy(self_p) result end |
#encode(data, size) ⇒ ::FFI::AutoPointer
Encode a stream of bytes into an armoured string. Returns the armoured string, or NULL if there was insufficient memory available to allocate a new string.
118 119 120 121 122 123 124 125 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 118 def encode(data, size) raise DestroyedError unless @ptr self_p = @ptr size = Integer(size) result = ::CZMQ::FFI.zarmour_encode(self_p, data, size) result = ::FFI::AutoPointer.new(result, LibC.method(:free)) result end |
#line_breaks ⇒ Boolean
Return if splitting output into lines is turned on. Default is off.
219 220 221 222 223 224 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 219 def line_breaks() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_line_breaks(self_p) result end |
#line_length ⇒ Integer
Get the line length used for splitting lines.
241 242 243 244 245 246 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 241 def line_length() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_line_length(self_p) result end |
#mode ⇒ Integer
Get the mode property.
144 145 146 147 148 149 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 144 def mode() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_mode(self_p) result end |
#mode_str ⇒ String
Get printable string for mode.
154 155 156 157 158 159 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 154 def mode_str() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_mode_str(self_p) result end |
#null? ⇒ Boolean
61 62 63 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 61 def null? !@ptr or @ptr.null? end |
#pad ⇒ Boolean
Return true if padding is turned on.
176 177 178 179 180 181 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 176 def pad() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_pad(self_p) result end |
#pad_char ⇒ ::FFI::Pointer
Get the padding character.
198 199 200 201 202 203 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 198 def pad_char() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_pad_char(self_p) result end |
#print ⇒ void
This method returns an undefined value.
Print properties of object
263 264 265 266 267 268 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 263 def print() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_print(self_p) result end |
#set_line_breaks(line_breaks) ⇒ void
This method returns an undefined value.
Turn splitting output into lines on or off.
230 231 232 233 234 235 236 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 230 def set_line_breaks(line_breaks) raise DestroyedError unless @ptr self_p = @ptr line_breaks = !(0==line_breaks||!line_breaks) # boolean result = ::CZMQ::FFI.zarmour_set_line_breaks(self_p, line_breaks) result end |
#set_line_length(line_length) ⇒ void
This method returns an undefined value.
Set the line length used for splitting lines.
252 253 254 255 256 257 258 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 252 def set_line_length(line_length) raise DestroyedError unless @ptr self_p = @ptr line_length = Integer(line_length) result = ::CZMQ::FFI.zarmour_set_line_length(self_p, line_length) result end |
#set_mode(mode) ⇒ void
This method returns an undefined value.
Set the mode property.
165 166 167 168 169 170 171 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 165 def set_mode(mode) raise DestroyedError unless @ptr self_p = @ptr mode = Integer(mode) result = ::CZMQ::FFI.zarmour_set_mode(self_p, mode) result end |
#set_pad(pad) ⇒ void
This method returns an undefined value.
Turn padding on or off. Default is on.
187 188 189 190 191 192 193 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 187 def set_pad(pad) raise DestroyedError unless @ptr self_p = @ptr pad = !(0==pad||!pad) # boolean result = ::CZMQ::FFI.zarmour_set_pad(self_p, pad) result end |
#set_pad_char(pad_char) ⇒ void
This method returns an undefined value.
Set the padding character.
209 210 211 212 213 214 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 209 def set_pad_char(pad_char) raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_set_pad_char(self_p, pad_char) result end |