Sha256: 99e5b4ad6b69001fca5833c0b376cc7aa827cd28c621036cf19f52e8c12c168c
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
#-- # ByteOrder # # Copyright (c) 2003 Michael Neumann # # ========================================================================== # Revision History :: # -------------------------------------------------------------------------- # 2005.04.28 TO * Minor modifications to documentation. # ========================================================================== # # :NOTE: This seems like a little much for what's really a single method. # In the future this should be reduced and moved to Nano Methods. # Only reason I haven't done so yet, is b/c BinaryReader # depends on it. # #++ #:title: ByteOrder # # ByteOrder module makes it possible to determine your systems # byte order, either big or little endian. # # == Usage # # ByteOrder.byteorder => :LittleEndian # # == Author(s) # # * Michael Neumann # # module ByteOrder Native = :Native BigEndian = Big = Network = :BigEndian LittleEndian = Little = :LittleEndian # examines the byte order of the underlying machine def byte_order if [0x12345678].pack("L") == "\x12\x34\x56\x78" BigEndian else LittleEndian end end alias_method :byteorder, :byte_order def little_endian? byte_order == LittleEndian end def big_endian? byte_order == BigEndian end alias little? little_endian? alias big? big_endian? alias network? big_endian? module_function :byte_order, :byteorder module_function :little_endian?, :little? module_function :big_endian?, :big?, :network? end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mega-0.3.1 | lib/mega/byteorder.rb |