2019-11-07 21:54:39 -05:00
|
|
|
class Array
|
|
|
|
# call-seq:
|
2022-10-18 11:16:22 -04:00
|
|
|
# pack(template, buffer: nil) -> string
|
2019-11-07 21:54:39 -05:00
|
|
|
#
|
2022-10-18 11:16:22 -04:00
|
|
|
# Formats each element in +self+ into a binary string; returns that string.
|
|
|
|
# See {Packed Data}[rdoc-ref:packed_data.rdoc].
|
2019-11-07 21:54:39 -05:00
|
|
|
def pack(fmt, buffer: nil)
|
2020-05-31 02:52:32 -04:00
|
|
|
Primitive.pack_pack(fmt, buffer)
|
2019-11-07 21:54:39 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class String
|
|
|
|
# call-seq:
|
2022-10-18 11:16:22 -04:00
|
|
|
# unpack(template, offset: 0) -> array
|
2019-11-07 21:54:39 -05:00
|
|
|
#
|
2022-10-18 11:16:22 -04:00
|
|
|
# Extracts data from +self+, forming objects that become the elements of a new array;
|
|
|
|
# returns that array.
|
|
|
|
# See {Packed Data}[rdoc-ref:packed_data.rdoc].
|
2021-10-18 10:23:54 -04:00
|
|
|
def unpack(fmt, offset: 0)
|
|
|
|
Primitive.pack_unpack(fmt, offset)
|
2019-11-07 21:54:39 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
# call-seq:
|
2022-10-18 11:16:22 -04:00
|
|
|
# unpack1(template, offset: 0) -> object
|
2021-12-23 15:58:13 -05:00
|
|
|
#
|
2022-10-18 11:16:22 -04:00
|
|
|
# Like String#unpack, but unpacks and returns only the first extracted object.
|
|
|
|
# See {Packed Data}[rdoc-ref:packed_data.rdoc].
|
2021-10-18 10:23:54 -04:00
|
|
|
def unpack1(fmt, offset: 0)
|
|
|
|
Primitive.pack_unpack1(fmt, offset)
|
2019-11-07 21:54:39 -05:00
|
|
|
end
|
|
|
|
end
|