Check system endianness using Ruby
today I’d like to share with you a simple way to check the endianness of your system using Ruby and it’s based on the “pack” method in Ruby’s Array; pack simply represents the content of an array in a binary sequence according to a directive given to it as an argument.
Using this method mades the endianness verification as simple as writing this snippet:
if .pack("I") == .pack("N")
The snippet verifies if the array  represented using native endianness (the “I” directive) is equal to the same array represented using network (big endian) endianness ( the “N” directive).
If the result is true the examined system is big endian, otherwise it is a little endian one.