Class: Steam::ByteReader
- Inherits:
-
Object
- Object
- Steam::ByteReader
- Extended by:
- Forwardable
- Defined in:
- lib/steam/byte_reader.rb
Overview
Reads bytes from a given IO object.
Instance Method Summary collapse
-
#initialize(io) ⇒ ByteReader
constructor
Create a ByteReader object.
-
#signed_int32 ⇒ Integer
Reads an signed 32 bit integer from the stream.
-
#string(len) ⇒ String
Reads a string of a given length from the stream.
-
#unsigned_int32 ⇒ Integer
Reads an unsigned 32 bit integer from the stream.
Constructor Details
#initialize(io) ⇒ ByteReader
Create a ByteReader object
12 13 14 |
# File 'lib/steam/byte_reader.rb', line 12 def initialize(io) @io = io end |
Instance Method Details
#signed_int32 ⇒ Integer
Reads an signed 32 bit integer from the stream
34 35 36 |
# File 'lib/steam/byte_reader.rb', line 34 def signed_int32 @io.read(4).unpack('<i*').first end |
#string(len) ⇒ String
Reads a string of a given length from the stream
20 21 22 |
# File 'lib/steam/byte_reader.rb', line 20 def string(len) read(len) end |
#unsigned_int32 ⇒ Integer
Reads an unsigned 32 bit integer from the stream
27 28 29 |
# File 'lib/steam/byte_reader.rb', line 27 def unsigned_int32 @io.read(4).unpack('<I*').first end |