Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/support/binary/core_ext/array.rb

Instance Method Summary collapse

Instance Method Details

#pack(*arguments, **kwargs) ⇒ String

Packs the Array into a String.

The desired architecture to pack the data for.

The Operating System (OS) to use.

Examples:

[0x1234, "hello"].pack(:uint16_le, :string)
# => "\x34\x12hello\0"

using a String#unpack format string:

[0x1234, "hello"].pack('vZ*')
# => "\x34\x12hello\0"

Parameters:

Options Hash (**kwargs):

  • :endian (:little, :big, :net, nil)

    The desired endianness to pack the data for.

  • :arch (:x86, :x86_64, :ppc, :ppc64, :arm, :arm_be, :arm64, :arm64_be, :mips, :mips_le, :mips64, :mips64_le, nil)
  • :os (:linux, :macos, :windows, :android, :apple_ios, :bsd, :freebsd, :openbsd, :netbsd)

Returns:

  • (String)

    The packed Array.

Raises:

See Also:

Since:

  • 0.5.0



71
72
73
74
75
76
77
78
# 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

#pack_originalObject



23
# File 'lib/ronin/support/binary/core_ext/array.rb', line 23

alias pack_original pack