lib/ronin/formatting/extensions/binary/float.rb in ronin-support-0.5.0 vs lib/ronin/formatting/extensions/binary/float.rb in ronin-support-0.5.1

- old
+ new

@@ -29,37 +29,37 @@ # # @return [String] # The packed float. # # @raise [ArgumentError] - # The argument was not a String code or a Symbol. + # The given Symbol could not be found in + # {Ronin::Binary::Template::FLOAT_TYPES}. # # @example using `Array#pack` template: # 0.42.pack('F') # # => =\n\xD7>" # # @example using {Ronin::Binary::Template} types: # 0x42.pack(:float_be) # # => ">\xD7\n=" # # @see http://rubydoc.info/stdlib/core/Array:pack + # @see Ronin::Binary::Template # # @since 0.5.0 # # @api public # def pack(argument) case argument when String [self].pack(argument) - when Symbol + else unless Ronin::Binary::Template::FLOAT_TYPES.include?(argument) raise(ArgumentError,"unsupported integer type: #{argument}") end [self].pack(Ronin::Binary::Template::TYPES[argument]) - else - raise(ArgumentError,"argument must be a String or a Symbol") end end end