Module: Ronin::Support::Binary::Stream::Methods Private

Included in:
IO, Ronin::Support::Binary::Stream
Defined in:
lib/ronin/support/binary/stream/methods.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds read_*/write_* methods for reading and writing binary data types.

Since:

  • 1.0.0

Reader Methods collapse

Writer Methods collapse

Instance Method Details

#read_array(type, length) ⇒ Binary::Array

Reads an array of the given type and length from the stream.

Parameters:

  • type (Symbol)

    The element type for the new array.

  • length (Integer)

    The number of elements for the new array.

Returns:

See Also:

Since:

  • 1.0.0



895
896
897
# File 'lib/ronin/support/binary/stream/methods.rb', line 895

def read_array(type,length)
  Array.read_from(self,type,length)
end

#read_array_of(type, count) ⇒ Array<Object>

Reads an array of the given type, starting at the given with the given length.

Parameters:

  • type (Symbol)

    The type of the value to read.

  • count (Integer)

    The number of desired elements within the array.

Returns:

  • (Array<Object>)

    The read array of types.

Since:

  • 1.0.0



432
433
434
435
436
437
438
# File 'lib/ronin/support/binary/stream/methods.rb', line 432

def read_array_of(type,count)
  type       = type_system[type]
  array_type = type[count]
  data       = read(array_type.size)

  return array_type.unpack(data)
end

#read_array_of_byte(count) ⇒ Array<Integer, nil> Also known as: read_bytes

Alias to read_array_of(:byte,count).

Parameters:

  • count (Integer)

    The number of bytes to read.

Returns:

See Also:

Since:

  • 1.0.0



453
454
455
# File 'lib/ronin/support/binary/stream/methods.rb', line 453

def read_array_of_byte(count)
  read_array_of(:byte,count)
end

#read_array_of_char(count) ⇒ Array<Integer, nil> Also known as: read_chars

Alias to read_array_of(:char,count).

Parameters:

  • count (Integer)

    The number of chars to read.

Returns:

See Also:

Since:

  • 1.0.0



472
473
474
# File 'lib/ronin/support/binary/stream/methods.rb', line 472

def read_array_of_char(count)
  read_array_of(:char,count)
end

#read_array_of_double(count) ⇒ Array<Float, nil> Also known as: read_doubles

Alias to read_array_of(:double,count).

Parameters:

  • count (Integer)

    The number of double values to read.

Returns:

  • (Array<Float, nil>)

    The read array of double values.

See Also:

Since:

  • 1.0.0



839
840
841
# File 'lib/ronin/support/binary/stream/methods.rb', line 839

def read_array_of_double(count)
  read_array_of(:double,count)
end

#read_array_of_float(count) ⇒ Array<Float, nil> Also known as: read_floats

Alias to read_array_of(:float,count).

Parameters:

  • count (Integer)

    The number of float values to read.

Returns:

  • (Array<Float, nil>)

    The read array of float values.

See Also:

Since:

  • 1.0.0



820
821
822
# File 'lib/ronin/support/binary/stream/methods.rb', line 820

def read_array_of_float(count)
  read_array_of(:float,count)
end

#read_array_of_float32(count) ⇒ Array<Float, nil>

Alias to read_array_of(:float32,count).

Parameters:

  • count (Integer)

    The number of float32 values to read.

Returns:

  • (Array<Float, nil>)

    The read array of float32 values.

See Also:

Since:

  • 1.0.0



786
787
788
# File 'lib/ronin/support/binary/stream/methods.rb', line 786

def read_array_of_float32(count)
  read_array_of(:float32,count)
end

#read_array_of_float64(count) ⇒ Array<Float, nil>

Alias to read_array_of(:float64,count).

Parameters:

  • count (Integer)

    The number of float64 values to read.

Returns:

  • (Array<Float, nil>)

    The read array of float64 values.

See Also:

Since:

  • 1.0.0



803
804
805
# File 'lib/ronin/support/binary/stream/methods.rb', line 803

def read_array_of_float64(count)
  read_array_of(:float64,count)
end

#read_array_of_int(count) ⇒ Array<Integer, nil> Also known as: read_ints

Alias to read_array_of(:int,count).

Parameters:

  • count (Integer)

    The number of int values to read.

Returns:

See Also:

Since:

  • 1.0.0



663
664
665
# File 'lib/ronin/support/binary/stream/methods.rb', line 663

def read_array_of_int(count)
  read_array_of(:int,count)
end

#read_array_of_int16(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int16,count).

Parameters:

  • count (Integer)

    The number of int16 values to read.

Returns:

See Also:

Since:

  • 1.0.0



527
528
529
# File 'lib/ronin/support/binary/stream/methods.rb', line 527

def read_array_of_int16(count)
  read_array_of(:int16,count)
end

#read_array_of_int32(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int32,count).

Parameters:

  • count (Integer)

    The number of int32 values to read.

Returns:

See Also:

Since:

  • 1.0.0



544
545
546
# File 'lib/ronin/support/binary/stream/methods.rb', line 544

def read_array_of_int32(count)
  read_array_of(:int32,count)
end

#read_array_of_int64(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int64,count).

Parameters:

  • count (Integer)

    The number of int64 values to read.

Returns:

See Also:

Since:

  • 1.0.0



561
562
563
# File 'lib/ronin/support/binary/stream/methods.rb', line 561

def read_array_of_int64(count)
  read_array_of(:int64,count)
end

#read_array_of_int8(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:int8,count).

Parameters:

  • count (Integer)

    The number of int8 values to read.

Returns:

See Also:

Since:

  • 1.0.0



510
511
512
# File 'lib/ronin/support/binary/stream/methods.rb', line 510

def read_array_of_int8(count)
  read_array_of(:int8,count)
end

#read_array_of_long(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:long,count).

Parameters:

  • count (Integer)

    The number of long values to read.

Returns:

See Also:

Since:

  • 1.0.0



682
683
684
# File 'lib/ronin/support/binary/stream/methods.rb', line 682

def read_array_of_long(count)
  read_array_of(:long,count)
end

#read_array_of_long_long(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:long_long,count).

Parameters:

  • count (Integer)

    The number of long_long values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of long_long values.

See Also:

Since:

  • 1.0.0



699
700
701
# File 'lib/ronin/support/binary/stream/methods.rb', line 699

def read_array_of_long_long(count)
  read_array_of(:long_long,count)
end

#read_array_of_short(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:short,count).

Parameters:

  • count (Integer)

    The number of short values to read.

Returns:

See Also:

Since:

  • 1.0.0



646
647
648
# File 'lib/ronin/support/binary/stream/methods.rb', line 646

def read_array_of_short(count)
  read_array_of(:short,count)
end

#read_array_of_uchar(count) ⇒ Array<Integer, nil> Also known as: read_uchars

Alias to read_array_of(:uchar,count).

Parameters:

  • count (Integer)

    The number of unsigned chars to read.

Returns:

  • (Array<Integer, nil>)

    The read array of unsigned chars.

See Also:

Since:

  • 1.0.0



491
492
493
# File 'lib/ronin/support/binary/stream/methods.rb', line 491

def read_array_of_uchar(count)
  read_array_of(:uchar,count)
end

#read_array_of_uint(count) ⇒ Array<Integer, nil> Also known as: read_uints

Alias to read_array_of(:uint,count).

Parameters:

  • count (Integer)

    The number of uint values to read.

Returns:

See Also:

Since:

  • 1.0.0



733
734
735
# File 'lib/ronin/support/binary/stream/methods.rb', line 733

def read_array_of_uint(count)
  read_array_of(:uint,count)
end

#read_array_of_uint16(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint16,count).

Parameters:

  • count (Integer)

    The number of uint16 values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of uint16 values.

See Also:

Since:

  • 1.0.0



595
596
597
# File 'lib/ronin/support/binary/stream/methods.rb', line 595

def read_array_of_uint16(count)
  read_array_of(:uint16,count)
end

#read_array_of_uint32(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint32,count).

Parameters:

  • count (Integer)

    The number of uint32 values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of uint32 values.

See Also:

Since:

  • 1.0.0



612
613
614
# File 'lib/ronin/support/binary/stream/methods.rb', line 612

def read_array_of_uint32(count)
  read_array_of(:uint32,count)
end

#read_array_of_uint64(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint64,count).

Parameters:

  • count (Integer)

    The number of uint64 values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of uint64 values.

See Also:

Since:

  • 1.0.0



629
630
631
# File 'lib/ronin/support/binary/stream/methods.rb', line 629

def read_array_of_uint64(count)
  read_array_of(:uint64,count)
end

#read_array_of_uint8(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:uint8,count).

Parameters:

  • count (Integer)

    The number of uint8 values to read.

Returns:

See Also:

Since:

  • 1.0.0



578
579
580
# File 'lib/ronin/support/binary/stream/methods.rb', line 578

def read_array_of_uint8(count)
  read_array_of(:uint8,count)
end

#read_array_of_ulong(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:ulong,count).

Parameters:

  • count (Integer)

    The number of ulong values to read.

Returns:

See Also:

Since:

  • 1.0.0



752
753
754
# File 'lib/ronin/support/binary/stream/methods.rb', line 752

def read_array_of_ulong(count)
  read_array_of(:ulong,count)
end

#read_array_of_ulong_long(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:ulong_long,count).

Parameters:

  • count (Integer)

    The number of ulong_long values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of ulong_long values.

See Also:

Since:

  • 1.0.0



769
770
771
# File 'lib/ronin/support/binary/stream/methods.rb', line 769

def read_array_of_ulong_long(count)
  read_array_of(:ulong_long,count)
end

#read_array_of_ushort(count) ⇒ Array<Integer, nil>

Alias to read_array_of(:ushort,count).

Parameters:

  • count (Integer)

    The number of ushort values to read.

Returns:

  • (Array<Integer, nil>)

    The read array of ushort values.

See Also:

Since:

  • 1.0.0



716
717
718
# File 'lib/ronin/support/binary/stream/methods.rb', line 716

def read_array_of_ushort(count)
  read_array_of(:ushort,count)
end

#read_buffer(count) ⇒ Buffer

Reads a buffer of count bytes from the stream.

Parameters:

  • count (Integer)

    The number of bytes to read from the stream.

Returns:

  • (Buffer)

    The newly read buffer.

See Also:

Since:

  • 1.0.0



875
876
877
# File 'lib/ronin/support/binary/stream/methods.rb', line 875

def read_buffer(count)
  Buffer.read_from(self,count)
end

#read_byteInteger

Alias for read_value(:byte).

Returns:

See Also:

Since:

  • 1.0.0



70
71
72
# File 'lib/ronin/support/binary/stream/methods.rb', line 70

def read_byte
  read_value(:byte)
end

#read_charString

Alias for read_value(:char).

Returns:

See Also:

Since:

  • 1.0.0



84
85
86
# File 'lib/ronin/support/binary/stream/methods.rb', line 84

def read_char
  read_value(:char)
end

#read_doubleFloat?

Alias for read_value(:double).

Returns:

  • (Float, nil)

    The read double.

See Also:

Since:

  • 1.0.0



413
414
415
# File 'lib/ronin/support/binary/stream/methods.rb', line 413

def read_double
  read_value(:double)
end

#read_floatFloat?

Alias for read_value(:float).

Returns:

  • (Float, nil)

    The read float.

See Also:

Since:

  • 1.0.0



399
400
401
# File 'lib/ronin/support/binary/stream/methods.rb', line 399

def read_float
  read_value(:float)
end

#read_float32Float?

Alias for read_value(:float32).

Returns:

  • (Float, nil)

    The read float32.

See Also:

Since:

  • 1.0.0



371
372
373
# File 'lib/ronin/support/binary/stream/methods.rb', line 371

def read_float32
  read_value(:float32)
end

#read_float64Float?

Alias for read_value(:float64).

Returns:

  • (Float, nil)

    The read float64.

See Also:

Since:

  • 1.0.0



385
386
387
# File 'lib/ronin/support/binary/stream/methods.rb', line 385

def read_float64
  read_value(:float64)
end

#read_intInteger?

Alias for read_value(:int).

Returns:

See Also:

Since:

  • 1.0.0



273
274
275
# File 'lib/ronin/support/binary/stream/methods.rb', line 273

def read_int
  read_value(:int)
end

#read_int16Integer?

Alias for read_value(:int16).

Returns:

  • (Integer, nil)

    The read int16.

See Also:

Since:

  • 1.0.0



161
162
163
# File 'lib/ronin/support/binary/stream/methods.rb', line 161

def read_int16
  read_value(:int16)
end

#read_int32Integer?

Alias for read_value(:int32).

Returns:

  • (Integer, nil)

    The read int32.

See Also:

Since:

  • 1.0.0



175
176
177
# File 'lib/ronin/support/binary/stream/methods.rb', line 175

def read_int32
  read_value(:int32)
end

#read_int64Integer?

Alias for read_value(:int64).

Returns:

  • (Integer, nil)

    The read int64.

See Also:

Since:

  • 1.0.0



189
190
191
# File 'lib/ronin/support/binary/stream/methods.rb', line 189

def read_int64
  read_value(:int64)
end

#read_int8Integer?

Alias for read_value(:int8).

Returns:

  • (Integer, nil)

    The read int8.

See Also:

Since:

  • 1.0.0



147
148
149
# File 'lib/ronin/support/binary/stream/methods.rb', line 147

def read_int8
  read_value(:int8)
end

#read_into(memory) ⇒ Buffer, ...

Reads data from the stream into the memory object.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0



858
859
860
# File 'lib/ronin/support/binary/stream/methods.rb', line 858

def read_into(memory)
  memory.read_from(self)
end

#read_longInteger?

Alias for read_value(:long).

Returns:

  • (Integer, nil)

    The read long.

See Also:

Since:

  • 1.0.0



287
288
289
# File 'lib/ronin/support/binary/stream/methods.rb', line 287

def read_long
  read_value(:long)
end

#read_long_longInteger?

Alias for read_value(:long_long).

Returns:

  • (Integer, nil)

    The read long_long.

See Also:

Since:

  • 1.0.0



301
302
303
# File 'lib/ronin/support/binary/stream/methods.rb', line 301

def read_long_long
  read_value(:long_long)
end

#read_shortInteger?

Alias for read_value(:short).

Returns:

  • (Integer, nil)

    The read short.

See Also:

Since:

  • 1.0.0



259
260
261
# File 'lib/ronin/support/binary/stream/methods.rb', line 259

def read_short
  read_value(:short)
end

#read_string(length = nil) ⇒ String

Reads a null-byte terminated C string from the buffer.

Parameters:

  • length (Integer, nil) (defaults to: nil)

    The optional maximum desired length of the string.

Returns:

  • (String)

    The read C string, without the null-byte.

Since:

  • 1.0.0



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/ronin/support/binary/stream/methods.rb', line 113

def read_string(length=nil)
  new_string = String.new('', encoding: external_encoding)

  if length
    length.times do
      if eof? || ((c = read(1)) == "\0")
        break
      end

      new_string << c
    end
  else
    until eof?
      if ((c = read(1)) == "\0")
        break
      end

      new_string << c
    end
  end

  return new_string
end

#read_struct(struct_class) ⇒ Binary::Struct

Reads a struct from the stream.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0



912
913
914
# File 'lib/ronin/support/binary/stream/methods.rb', line 912

def read_struct(struct_class)
  struct_class.read_from(self)
end

#read_ucharString

Alias for read_value(:uchar).

Returns:

  • (String)

    The read uchar.

See Also:

Since:

  • 1.0.0



98
99
100
# File 'lib/ronin/support/binary/stream/methods.rb', line 98

def read_uchar
  read_value(:uchar)
end

#read_uintInteger?

Alias for read_value(:uint).

Returns:

  • (Integer, nil)

    The read uint.

See Also:

Since:

  • 1.0.0



329
330
331
# File 'lib/ronin/support/binary/stream/methods.rb', line 329

def read_uint
  read_value(:uint)
end

#read_uint16Integer?

Alias for read_value(:uint16).

Returns:

  • (Integer, nil)

    The read uint16.

See Also:

Since:

  • 1.0.0



217
218
219
# File 'lib/ronin/support/binary/stream/methods.rb', line 217

def read_uint16
  read_value(:uint16)
end

#read_uint32Integer?

Alias for read_value(:uint32).

Returns:

  • (Integer, nil)

    The read uint32.

See Also:

Since:

  • 1.0.0



231
232
233
# File 'lib/ronin/support/binary/stream/methods.rb', line 231

def read_uint32
  read_value(:uint32)
end

#read_uint64Integer?

Alias for read_value(:uint64).

Returns:

  • (Integer, nil)

    The read uint64.

See Also:

Since:

  • 1.0.0



245
246
247
# File 'lib/ronin/support/binary/stream/methods.rb', line 245

def read_uint64
  read_value(:uint64)
end

#read_uint8Integer?

Alias for read_value(:uint8).

Returns:

  • (Integer, nil)

    The read uint8.

See Also:

Since:

  • 1.0.0



203
204
205
# File 'lib/ronin/support/binary/stream/methods.rb', line 203

def read_uint8
  read_value(:uint8)
end

#read_ulongInteger?

Alias for read_value(:ulong).

Returns:

  • (Integer, nil)

    The read ulong.

See Also:

Since:

  • 1.0.0



343
344
345
# File 'lib/ronin/support/binary/stream/methods.rb', line 343

def read_ulong
  read_value(:ulong)
end

#read_ulong_longInteger?

Alias for read_value(:ulong_long).

Returns:

  • (Integer, nil)

    The read ulong_long.

See Also:

Since:

  • 1.0.0



357
358
359
# File 'lib/ronin/support/binary/stream/methods.rb', line 357

def read_ulong_long
  read_value(:ulong_long)
end

#read_union(union_class) ⇒ Binary::Union

Reads a union from the stream.

Parameters:

Returns:

See Also:

Since:

  • 1.0.0



929
930
931
# File 'lib/ronin/support/binary/stream/methods.rb', line 929

def read_union(union_class)
  union_class.read_from(self)
end

#read_ushortInteger?

Alias for read_value(:ushort).

Returns:

  • (Integer, nil)

    The read ushort.

See Also:

Since:

  • 1.0.0



315
316
317
# File 'lib/ronin/support/binary/stream/methods.rb', line 315

def read_ushort
  read_value(:ushort)
end

#read_value(type) ⇒ Integer, ...

Reads a value of the given type from the IO stream.

Parameters:

  • type (Symbol)

    The desired type of data to read.

Returns:

Since:

  • 1.0.0



52
53
54
55
56
57
58
# File 'lib/ronin/support/binary/stream/methods.rb', line 52

def read_value(type)
  type  = type_system[type]

  if (slice = read(type.size))
    type.unpack(slice)
  end
end

#write_array_of(type, array) ⇒ self

Writes an array of the given type.

Parameters:

  • type (Symbol)

    The type of the value to write.

  • array (Array<Object>)

    The array of values to write.

Returns:

  • (self)

Since:

  • 1.0.0



1361
1362
1363
1364
1365
1366
1367
1368
# File 'lib/ronin/support/binary/stream/methods.rb', line 1361

def write_array_of(type,array)
  type       = type_system[type]
  array_type = type[array.length]
  data       = array_type.pack(array)

  write(data)
  return self
end

#write_array_of_byte(bytes) ⇒ self Also known as: write_bytes

Alias to write_array_of(:byte,bytes).

Parameters:

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1382
1383
1384
# File 'lib/ronin/support/binary/stream/methods.rb', line 1382

def write_array_of_byte(bytes)
  write_array_of(:byte,bytes)
end

#write_array_of_char(chars) ⇒ self Also known as: write_chars

Alias to write_array_of(:char,bytes).

Parameters:

  • chars (String)

    The array of characters to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1400
1401
1402
# File 'lib/ronin/support/binary/stream/methods.rb', line 1400

def write_array_of_char(chars)
  write_array_of(:char,chars)
end

#write_array_of_double(floats) ⇒ self Also known as: write_doubles

Alias to write_array_of(:double,floats).

Parameters:

  • floats (Array<Float>)

    The array of double values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1746
1747
1748
# File 'lib/ronin/support/binary/stream/methods.rb', line 1746

def write_array_of_double(floats)
  write_array_of(:double,floats)
end

#write_array_of_float(floats) ⇒ self Also known as: write_floats

Alias to write_array_of(:float,floats).

Parameters:

  • floats (Array<Float>)

    The array of float values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1728
1729
1730
# File 'lib/ronin/support/binary/stream/methods.rb', line 1728

def write_array_of_float(floats)
  write_array_of(:float,floats)
end

#write_array_of_float32(floats) ⇒ self

Alias to write_array_of(:float32,floats).

Parameters:

  • floats (Array<Float>)

    The array of float32 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1696
1697
1698
# File 'lib/ronin/support/binary/stream/methods.rb', line 1696

def write_array_of_float32(floats)
  write_array_of(:float32,floats)
end

#write_array_of_float64(floats) ⇒ self

Alias to write_array_of(:float64,floats).

Parameters:

  • floats (Array<Float>)

    The array of float64 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1712
1713
1714
# File 'lib/ronin/support/binary/stream/methods.rb', line 1712

def write_array_of_float64(floats)
  write_array_of(:float64,floats)
end

#write_array_of_int(ints) ⇒ self Also known as: write_ints

Alias to write_array_of(:int,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1580
1581
1582
# File 'lib/ronin/support/binary/stream/methods.rb', line 1580

def write_array_of_int(ints)
  write_array_of(:int,ints)
end

#write_array_of_int16(ints) ⇒ self

Alias to write_array_of(:int16,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int16 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1452
1453
1454
# File 'lib/ronin/support/binary/stream/methods.rb', line 1452

def write_array_of_int16(ints)
  write_array_of(:int16,ints)
end

#write_array_of_int32(ints) ⇒ self

Alias to write_array_of(:int32,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int32 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1468
1469
1470
# File 'lib/ronin/support/binary/stream/methods.rb', line 1468

def write_array_of_int32(ints)
  write_array_of(:int32,ints)
end

#write_array_of_int64(ints) ⇒ self

Alias to write_array_of(:int64,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int64 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1484
1485
1486
# File 'lib/ronin/support/binary/stream/methods.rb', line 1484

def write_array_of_int64(ints)
  write_array_of(:int64,ints)
end

#write_array_of_int8(ints) ⇒ self

Alias to write_array_of(:int8,ints).

Parameters:

  • ints (Array<Integer>)

    The array of int8 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1436
1437
1438
# File 'lib/ronin/support/binary/stream/methods.rb', line 1436

def write_array_of_int8(ints)
  write_array_of(:int8,ints)
end

#write_array_of_long(ints) ⇒ self

Alias to write_array_of(:long,ints).

Parameters:

  • ints (Array<Integer>)

    The array of long values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1598
1599
1600
# File 'lib/ronin/support/binary/stream/methods.rb', line 1598

def write_array_of_long(ints)
  write_array_of(:long,ints)
end

#write_array_of_long_long(ints) ⇒ self

Alias to write_array_of(:long_long,ints).

Parameters:

  • ints (Array<Integer>)

    The array of long_long values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1614
1615
1616
# File 'lib/ronin/support/binary/stream/methods.rb', line 1614

def write_array_of_long_long(ints)
  write_array_of(:long_long,ints)
end

#write_array_of_short(ints) ⇒ self

Alias to write_array_of(:short,ints).

Parameters:

  • ints (Array<Integer>)

    The array of short values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1564
1565
1566
# File 'lib/ronin/support/binary/stream/methods.rb', line 1564

def write_array_of_short(ints)
  write_array_of(:short,ints)
end

#write_array_of_uchar(chars) ⇒ self Also known as: write_uchars

Alias to write_array_of(:uchar,bytes).

Parameters:

  • chars (String)

    The array of unsigned characters to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1418
1419
1420
# File 'lib/ronin/support/binary/stream/methods.rb', line 1418

def write_array_of_uchar(chars)
  write_array_of(:uchar,chars)
end

#write_array_of_uint(uints) ⇒ self Also known as: write_uints

Alias to write_array_of(:uint,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1646
1647
1648
# File 'lib/ronin/support/binary/stream/methods.rb', line 1646

def write_array_of_uint(uints)
  write_array_of(:uint,uints)
end

#write_array_of_uint16(uints) ⇒ self

Alias to write_array_of(:uint16,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint16 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1516
1517
1518
# File 'lib/ronin/support/binary/stream/methods.rb', line 1516

def write_array_of_uint16(uints)
  write_array_of(:uint16,uints)
end

#write_array_of_uint32(uints) ⇒ self

Alias to write_array_of(:uint32,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint32 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1532
1533
1534
# File 'lib/ronin/support/binary/stream/methods.rb', line 1532

def write_array_of_uint32(uints)
  write_array_of(:uint32,uints)
end

#write_array_of_uint64(uints) ⇒ self

Alias to write_array_of(:uint64,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint64 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1548
1549
1550
# File 'lib/ronin/support/binary/stream/methods.rb', line 1548

def write_array_of_uint64(uints)
  write_array_of(:uint64,uints)
end

#write_array_of_uint8(uints) ⇒ self

Alias to write_array_of(:uint8,uints).

Parameters:

  • uints (Array<Integer>)

    The array of uint8 values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1500
1501
1502
# File 'lib/ronin/support/binary/stream/methods.rb', line 1500

def write_array_of_uint8(uints)
  write_array_of(:uint8,uints)
end

#write_array_of_ulong(uints) ⇒ self

Alias to write_array_of(:ulong,uints).

Parameters:

  • uints (Array<Integer>)

    The array of ulong values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1664
1665
1666
# File 'lib/ronin/support/binary/stream/methods.rb', line 1664

def write_array_of_ulong(uints)
  write_array_of(:ulong,uints)
end

#write_array_of_ulong_long(uints) ⇒ self

Alias to write_array_of(:ulong_long,uints).

Parameters:

  • uints (Array<Integer>)

    The array of ulong_long values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1680
1681
1682
# File 'lib/ronin/support/binary/stream/methods.rb', line 1680

def write_array_of_ulong_long(uints)
  write_array_of(:ulong_long,uints)
end

#write_array_of_ushort(uints) ⇒ self

Alias to write_array_of(:ushort,uints).

Parameters:

  • uints (Array<Integer>)

    The array of ushort values to write.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1630
1631
1632
# File 'lib/ronin/support/binary/stream/methods.rb', line 1630

def write_array_of_ushort(uints)
  write_array_of(:ushort,uints)
end

#write_byte(value) ⇒ self

Alias for write_value(:byte,value).

Parameters:

  • value (Integer)

    The char value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



970
971
972
# File 'lib/ronin/support/binary/stream/methods.rb', line 970

def write_byte(value)
  write_value(:byte,value)
end

#write_char(value) ⇒ self

Alias for write_value(:char,value).

Parameters:

  • value (String)

    The char value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



986
987
988
# File 'lib/ronin/support/binary/stream/methods.rb', line 986

def write_char(value)
  write_value(:char,value)
end

#write_double(value) ⇒ self

Alias for write_value(:double,value).

Parameters:

  • value (Float)

    The double value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1344
1345
1346
# File 'lib/ronin/support/binary/stream/methods.rb', line 1344

def write_double(value)
  write_value(:double,value)
end

#write_float(value) ⇒ self

Alias for write_value(:float,value).

Parameters:

  • value (Float)

    The float value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1328
1329
1330
# File 'lib/ronin/support/binary/stream/methods.rb', line 1328

def write_float(value)
  write_value(:float,value)
end

#write_float32(value) ⇒ self

Alias for write_value(:float32,value).

Parameters:

  • value (Float)

    The float32 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1296
1297
1298
# File 'lib/ronin/support/binary/stream/methods.rb', line 1296

def write_float32(value)
  write_value(:float32,value)
end

#write_float64(value) ⇒ self

Alias for write_value(:float64,value).

Parameters:

  • value (Float)

    The float64 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1312
1313
1314
# File 'lib/ronin/support/binary/stream/methods.rb', line 1312

def write_float64(value)
  write_value(:float64,value)
end

#write_int(value) ⇒ self

Alias for write_value(:int,value).

Parameters:

  • value (Integer)

    The int value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1184
1185
1186
# File 'lib/ronin/support/binary/stream/methods.rb', line 1184

def write_int(value)
  write_value(:int,value)
end

#write_int16(value) ⇒ self

Alias for write_value(:int16,value).

Parameters:

  • value (Integer)

    The int16 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1056
1057
1058
# File 'lib/ronin/support/binary/stream/methods.rb', line 1056

def write_int16(value)
  write_value(:int16,value)
end

#write_int32(value) ⇒ self

Alias for write_value(:int32,value).

Parameters:

  • value (Integer)

    The int32 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1072
1073
1074
# File 'lib/ronin/support/binary/stream/methods.rb', line 1072

def write_int32(value)
  write_value(:int32,value)
end

#write_int64(value) ⇒ self

Alias for write_value(:int64,value).

Parameters:

  • value (Integer)

    The int64 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1088
1089
1090
# File 'lib/ronin/support/binary/stream/methods.rb', line 1088

def write_int64(value)
  write_value(:int64,value)
end

#write_int8(value) ⇒ self

Alias for write_value(:int8,value).

Parameters:

  • value (Integer)

    The int8 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1040
1041
1042
# File 'lib/ronin/support/binary/stream/methods.rb', line 1040

def write_int8(value)
  write_value(:int8,value)
end

#write_long(value) ⇒ self

Alias for write_value(:long,value).

Parameters:

  • value (Integer)

    The long value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1200
1201
1202
# File 'lib/ronin/support/binary/stream/methods.rb', line 1200

def write_long(value)
  write_value(:long,value)
end

#write_long_long(value) ⇒ self

Alias for write_value(:long_long,value).

Parameters:

  • value (Integer)

    The long_long value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1216
1217
1218
# File 'lib/ronin/support/binary/stream/methods.rb', line 1216

def write_long_long(value)
  write_value(:long_long,value)
end

#write_short(value) ⇒ self

Alias for write_value(:short,value).

Parameters:

  • value (Integer)

    The short value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1168
1169
1170
# File 'lib/ronin/support/binary/stream/methods.rb', line 1168

def write_short(value)
  write_value(:short,value)
end

#write_string(string) ⇒ self

Writes a null-terminated C string to the buffer.

Parameters:

  • string (String)

    The String to write into the buffer.

Returns:

  • (self)

Since:

  • 1.0.0



1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
# File 'lib/ronin/support/binary/stream/methods.rb', line 1000

def write_string(string)
  ascii_string = string.encode(Encoding::ASCII_8BIT)
  cstring      = if ascii_string.end_with?("\0")
                   ascii_string
                 else
                   "#{ascii_string}\0"
                 end

  write(cstring)
  return self
end

#write_uchar(value) ⇒ self

Alias for write_value(:uchar,value).

Parameters:

  • value (String)

    The uchar value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1024
1025
1026
# File 'lib/ronin/support/binary/stream/methods.rb', line 1024

def write_uchar(value)
  write_value(:uchar,value)
end

#write_uint(value) ⇒ self

Alias for write_value(:uint,value).

Parameters:

  • value (Integer)

    The uint value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1248
1249
1250
# File 'lib/ronin/support/binary/stream/methods.rb', line 1248

def write_uint(value)
  write_value(:uint,value)
end

#write_uint16(value) ⇒ self

Alias for write_value(:uint16,value).

Parameters:

  • value (Integer)

    The uint16 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1120
1121
1122
# File 'lib/ronin/support/binary/stream/methods.rb', line 1120

def write_uint16(value)
  write_value(:uint16,value)
end

#write_uint32(value) ⇒ self

Alias for write_value(:uint32,value).

Parameters:

  • value (Integer)

    The uint32 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1136
1137
1138
# File 'lib/ronin/support/binary/stream/methods.rb', line 1136

def write_uint32(value)
  write_value(:uint32,value)
end

#write_uint64(value) ⇒ self

Alias for write_value(:uint64,value).

Parameters:

  • value (Integer)

    The uint64 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1152
1153
1154
# File 'lib/ronin/support/binary/stream/methods.rb', line 1152

def write_uint64(value)
  write_value(:uint64,value)
end

#write_uint8(value) ⇒ self

Alias for write_value(:uint8,value).

Parameters:

  • value (Integer)

    The uint8 value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1104
1105
1106
# File 'lib/ronin/support/binary/stream/methods.rb', line 1104

def write_uint8(value)
  write_value(:uint8,value)
end

#write_ulong(value) ⇒ self

Alias for write_value(:ulong,value).

Parameters:

  • value (Integer)

    The ulong value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1264
1265
1266
# File 'lib/ronin/support/binary/stream/methods.rb', line 1264

def write_ulong(value)
  write_value(:ulong,value)
end

#write_ulong_long(value) ⇒ self

Alias for write_value(:ulong_long,value).

Parameters:

  • value (Integer)

    The ulong_long value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1280
1281
1282
# File 'lib/ronin/support/binary/stream/methods.rb', line 1280

def write_ulong_long(value)
  write_value(:ulong_long,value)
end

#write_ushort(value) ⇒ self

Alias for write_value(:ushort,value).

Parameters:

  • value (Integer)

    The ushort value to write into the buffer.

Returns:

  • (self)

See Also:

Since:

  • 1.0.0



1232
1233
1234
# File 'lib/ronin/support/binary/stream/methods.rb', line 1232

def write_ushort(value)
  write_value(:ushort,value)
end

#write_value(type, value) ⇒ self

Writes the value to the IO stream.

Parameters:

  • type (Symbol)

    The type of value to write.

  • value (Integer, Float, String)

    The value to write.

Returns:

  • (self)

Since:

  • 1.0.0



950
951
952
953
954
955
956
# File 'lib/ronin/support/binary/stream/methods.rb', line 950

def write_value(type,value)
  type = type_system[type]
  data = type.pack(value)

  write(data)
  return self
end