class Array
Public Instance Methods
pack(*arguments,**kwargs)
click to toggle source
Packs the Array
into a String
.
@param [String, Array
<Symbol, (Symbol, Integer
)>] arguments
The `Array#pack` format string or a list of {Ronin::Support::Binary::Template} types.
@param [Hash{Symbol => Object}] kwargs
Additional keyword arguments for {Ronin::Support::Binary::Template#initialize}.
@option kwargs [:little, :big, :net, nil] :endian
The desired endianness to pack the data for.
@option kwargs [:x86, :x86_64, :ppc, :ppc64,
:arm, :arm_be, :arm64, :arm64_be, :mips, :mips_le, :mips64, :mips64_le, nil] :arch The desired architecture to pack the data for.
@option kwargs [:linux, :macos, :windows,
:android, :apple_ios, :bsd, :freebsd, :openbsd, :netbsd] :os The Operating System (OS) to use.
@return [String]
The packed Array.
@raise [ArgumentError]
One of the arguments was not a known {Ronin::Support::Binary::Template} type.
@example using {Ronin::Support::Binary::Template} types:
[0x1234, "hello"].pack(:uint16_le, :string) # => "\x34\x12hello\0"
@example using a ‘String#unpack` format string:
[0x1234, "hello"].pack('vZ*') # => "\x34\x12hello\0"
@see rubydoc.info/stdlib/core/Array:pack @see Ronin::Support::Binary::Template
@since 0.5.0
@api public
# File lib/ronin/support/binary/core_ext/array.rb, line 71 def pack(*arguments,**kwargs) if (arguments.length == 1 && arguments.first.kind_of?(String)) pack_original(arguments.first) else template = Ronin::Support::Binary::Template.new(arguments,**kwargs) template.pack(*self) end end
Also aliased as: pack_original