Module: Lignite::Bytes

Included in:
Assembler, Message, Message, MessageSender, OpCompiler, RbfObject, SystemCommands
Defined in:
lib/lignite/bytes.rb

Instance Method Summary collapse

Instance Method Details

#f32(float) ⇒ Object



15
16
17
# File 'lib/lignite/bytes.rb', line 15

def f32(float)
  [float].pack("e")
end

#hexdump(s) ⇒ Object



31
32
33
# File 'lib/lignite/bytes.rb', line 31

def hexdump(s)
  s.unpack("H*").first
end

#u16(n) ⇒ Object



7
8
9
# File 'lib/lignite/bytes.rb', line 7

def u16(n)
  u8(n & 0xff) + u8(n >> 8)
end

#u32(n) ⇒ Object



11
12
13
# File 'lib/lignite/bytes.rb', line 11

def u32(n)
  u16(n & 0xffff) + u16(n >> 16)
end

#u8(n) ⇒ Object



3
4
5
# File 'lib/lignite/bytes.rb', line 3

def u8(n)
  (n & 0xff).chr
end

#unpack_u16(s) ⇒ Object



23
24
25
# File 'lib/lignite/bytes.rb', line 23

def unpack_u16(s)
  s.unpack("S<").first
end

#unpack_u32(s) ⇒ Object



27
28
29
# File 'lib/lignite/bytes.rb', line 27

def unpack_u32(s)
  s.unpack("L<").first
end

#unpack_u8(s) ⇒ Object



19
20
21
# File 'lib/lignite/bytes.rb', line 19

def unpack_u8(s)
  s.unpack("C").first
end