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