Module: ByteOrder

Defined in:
lib/carat/byteorder.rb

Overview

by Michael Neumann

Constant Summary collapse

Native =
:Native
BigEndian =
Big = Network = :BigEndian
LittleEndian =
Little = :LittleEndian

Class Method Summary collapse

Class Method Details

.big?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/carat/byteorder.rb', line 28

def big_endian?
  byte_order == BigEndian
end

.big_endian?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/carat/byteorder.rb', line 23

def big_endian?
  byte_order == BigEndian
end

.byte_orderObject

examines the byte order of the underlying machine



9
10
11
12
13
14
15
# File 'lib/carat/byteorder.rb', line 9

def byte_order
  if [0x12345678].pack("L") == "\x12\x34\x56\x78" 
    BigEndian
  else
    LittleEndian
  end
end

.byteorderObject

examines the byte order of the underlying machine



17
18
19
20
21
22
23
# File 'lib/carat/byteorder.rb', line 17

def byte_order
  if [0x12345678].pack("L") == "\x12\x34\x56\x78" 
    BigEndian
  else
    LittleEndian
  end
end

.little?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/carat/byteorder.rb', line 27

def little_endian?
  byte_order == LittleEndian
end

.little_endian?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/carat/byteorder.rb', line 19

def little_endian?
  byte_order == LittleEndian
end

.network?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/carat/byteorder.rb', line 29

def big_endian?
  byte_order == BigEndian
end