From: "mame (Yusuke Endoh) via ruby-dev" Date: 2023-10-13T13:00:46+00:00 Subject: [ruby-dev:52054] [Ruby master Feature#18573] Object#pack1 Issue #18573 has been updated by mame (Yusuke Endoh). If we introduce a new method for this, I think it would be better to design a more descriptive API instead of reusing a hacky pack format directive, such as `0x1234.to_binary_string(4, endian: :big) #=> "\x00\x00\x12\x34"`. ---------------------------------------- Feature #18573: Object#pack1 https://bugs.ruby-lang.org/issues/18573#change-104913 * Author: os (Shigeki OHARA) * Status: Open * Priority: Normal ---------------------------------------- # ������ String#unpack1 ��������� Object#pack1 ��������������� # ������ Array#pack ������������������������������������������������������������ Array ��������������� 1 ��������������������������������������������� ``` ruby [codepoint].pack('U') [digest].pack('m0') [mail_body].pack('M') [ip_address].pack('N') ``` ������������������������������������������������������������������������������������������ ��������������������������������������������������������������������������������������� Array ������������������������������������������������������������������������������ # ������ String#unpack ������������ String#unpack1 ������������������������������������������ Array#pack ������������ Object#pack1 ������������������������������������������ ��������������������������������������������������������������������� ``` ruby class Object def pack1(template, option = {}) [self].pack(template, **option) end end ``` # ��������������� * Object ��������������������������������������������������������������������� * ������������������ pack1 ������������������������������������������������������������������������������������������ -- https://bugs.ruby-lang.org/