Class: CSstats::Parser::Reader::FileStreamer
- Inherits:
-
Object
- Object
- CSstats::Parser::Reader::FileStreamer
- Defined in:
- lib/csstats/parser/reader/file_streamer.rb
Instance Attribute Summary collapse
-
#stream ⇒ Object
readonly
Returns the value of attribute stream.
Instance Method Summary collapse
-
#initialize(stream) ⇒ FileStreamer
constructor
A new instance of FileStreamer.
-
#read_int_data ⇒ Object
Internal: Get the 32bit integer from file.
-
#read_short_data ⇒ Object
Internal: Get the 16bit integer from file.
-
#read_string_data(length) ⇒ Object
Internal: Get the String from file.
Constructor Details
#initialize(stream) ⇒ FileStreamer
Returns a new instance of FileStreamer.
9 10 11 |
# File 'lib/csstats/parser/reader/file_streamer.rb', line 9 def initialize(stream) @stream = stream end |
Instance Attribute Details
#stream ⇒ Object (readonly)
Returns the value of attribute stream.
7 8 9 |
# File 'lib/csstats/parser/reader/file_streamer.rb', line 7 def stream @stream end |
Instance Method Details
#read_int_data ⇒ Object
Internal: Get the 32bit integer from file.
Returns the Integer.
16 17 18 19 20 21 |
# File 'lib/csstats/parser/reader/file_streamer.rb', line 16 def read_int_data data = stream.read(4) raise CSstats::Error, 'Cannot read int data.' unless data data.unpack1('V') end |
#read_short_data ⇒ Object
Internal: Get the 16bit integer from file.
Returns the Integer.
26 27 28 29 30 31 |
# File 'lib/csstats/parser/reader/file_streamer.rb', line 26 def read_short_data data = stream.read(2) raise CSstats::Error, 'Cannot read short data.' unless data data.unpack1('v') end |
#read_string_data(length) ⇒ Object
Internal: Get the String from file.
length - The Integer length of string to read.
Returns the String.
38 39 40 41 42 43 |
# File 'lib/csstats/parser/reader/file_streamer.rb', line 38 def read_string_data(length) data = stream.read(length) raise CSstats::Error, 'Cannot read string data.' unless data data.strip end |