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 60 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 53 def self.create_finalizer_for(ptr) ptr_ptr = ::FFI::MemoryPointer.new :pointer Proc.new do ptr_ptr.write_pointer ptr ::CZMQ::FFI.zarmour_destroy ptr_ptr end end |
Instance Method Details
#__ptr ⇒ ::FFI::Pointer Also known as: to_ptr
Return internal pointer
67 68 69 70 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 67 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.
78 79 80 81 82 83 84 85 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 78 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.
90 91 92 93 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 90 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.
134 135 136 137 138 139 140 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 134 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
105 106 107 108 109 110 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 105 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.
119 120 121 122 123 124 125 126 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 119 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.
220 221 222 223 224 225 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 220 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.
242 243 244 245 246 247 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 242 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.
145 146 147 148 149 150 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 145 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.
155 156 157 158 159 160 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 155 def mode_str() raise DestroyedError unless @ptr self_p = @ptr result = ::CZMQ::FFI.zarmour_mode_str(self_p) result end |
#null? ⇒ Boolean
62 63 64 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 62 def null? !@ptr or @ptr.null? end |
#pad ⇒ Boolean
Return true if padding is turned on.
177 178 179 180 181 182 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 177 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.
199 200 201 202 203 204 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 199 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
264 265 266 267 268 269 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 264 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.
231 232 233 234 235 236 237 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 231 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.
253 254 255 256 257 258 259 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 253 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.
166 167 168 169 170 171 172 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 166 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.
188 189 190 191 192 193 194 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 188 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.
210 211 212 213 214 215 |
# File 'lib/czmq-ffi-gen/czmq/ffi/zarmour.rb', line 210 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 |