class Float
Public Instance Methods
Source
# File lib/ronin/support/binary/core_ext/float.rb, line 70 def pack(argument, **kwargs) case argument when String [self].pack(argument) else types = Ronin::Support::Binary::CTypes.platform(**kwargs) type = types[argument] type.pack(self) end end
Packs the Float
into a String
.
@param [String, Symbol] argument
The `Array#pack` format string or {Ronin::Support::Binary::Template} type.
@param [Hash{Symbol => Object}] kwargs
Additional keyword arguments for {Ronin::Support::Binary::CTypes.platform}.
@option kwargs [:little, :big, :net, nil] :endian
The desired endianness of the binary format.
@option kwargs [:x86, :x86_64,
:ppc, :ppc64, :mips, :mips_le, :mips_be, :mips64, :mips64_le, :mips64_be, :arm, :arm_le, :arm_be, :arm64, :arm64_le, :arm64_be] :arch The desired architecture of the binary format.
@option kwargs [:linux, :macos, :windows,
:android, :apple_ios, :bsd, :freebsd, :openbsd, :netbsd] :os The Operating System name to lookup.
@return [String]
The packed float.
@raise [ArgumentError]
The given argument was not a `String`, `Symbol`, or valid type name.
@example using ‘Array#pack` format string:
0.42.pack('F') # => =\n\xD7>"
@example using {Ronin::Support::Binary::Template} types:
0x42.pack(:float_be) # => ">\xD7\n="
@see rubydoc.info/stdlib/core/Array:pack @see Ronin::Support::Binary::Template
@since 0.5.0
@api public