module BinaryWriterMixin
Public Instance Methods
write_int16_little(val)
click to toggle source
# File lib/binary_writer.rb, line 45 def write_int16_little(val) pw(val, 'v') end
write_int16_native(val)
click to toggle source
write_int16_network(val)
click to toggle source
# File lib/binary_writer.rb, line 49 def write_int16_network(val) pw(val, 'n') end
write_int32_little(val)
click to toggle source
# File lib/binary_writer.rb, line 79 def write_int32_little(val) pw(val, 'V') end
write_int32_native(val)
click to toggle source
write_int32_network(val)
click to toggle source
# File lib/binary_writer.rb, line 83 def write_int32_network(val) pw(val, 'N') end
write_int8(val)
click to toggle source
# File lib/binary_writer.rb, line 13 def write_int8(val) pw(val, 'c') end
write_word16_little(val)
click to toggle source
# File lib/binary_writer.rb, line 27 def write_word16_little(val) str = [val].pack('S') str.reverse! if ByteOrder.network? # swap bytes as native=network (and we want little) write(str) end
write_word16_native(val)
click to toggle source
write_word16_network(val)
click to toggle source
# File lib/binary_writer.rb, line 33 def write_word16_network(val) str = [val].pack('S') str.reverse! if ByteOrder.little? # swap bytes as native=little (and we want network) write(str) end
write_word32_little(val)
click to toggle source
# File lib/binary_writer.rb, line 61 def write_word32_little(val) str = [val].pack('L') str.reverse! if ByteOrder.network? # swap bytes as native=network (and we want little) write(str) end
write_word32_native(val)
click to toggle source
write_word32_network(val)
click to toggle source
# File lib/binary_writer.rb, line 67 def write_word32_network(val) str = [val].pack('L') str.reverse! if ByteOrder.little? # swap bytes as native=little (and we want network) write(str) end
write_word8(val)
click to toggle source
no byteorder for 8 bit!
# File lib/binary_writer.rb, line 9 def write_word8(val) pw(val, 'C') end
Also aliased as: write_byte
Private Instance Methods
pw(val, template)
click to toggle source
shortcut for pack and write
# File lib/binary_writer.rb, line 97 def pw(val, template) write([val].pack(template)) end