Class: CSstats::Parser::FileReader::Handler
- Inherits:
-
Object
- Object
- CSstats::Parser::FileReader::Handler
- Defined in:
- lib/csstats/parser/file_reader/handler.rb
Instance Attribute Summary collapse
-
#handle ⇒ Object
readonly
Returns the value of attribute handle.
Instance Method Summary collapse
-
#initialize(handle) ⇒ Handler
constructor
A new instance of Handler.
-
#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(handle) ⇒ Handler
Returns a new instance of Handler.
7 8 9 |
# File 'lib/csstats/parser/file_reader/handler.rb', line 7 def initialize(handle) @handle = handle end |
Instance Attribute Details
#handle ⇒ Object (readonly)
Returns the value of attribute handle.
5 6 7 |
# File 'lib/csstats/parser/file_reader/handler.rb', line 5 def handle @handle end |
Instance Method Details
#read_int_data ⇒ Object
Internal: Get the 32bit integer from file.
Returns the Integer.
14 15 16 17 18 19 |
# File 'lib/csstats/parser/file_reader/handler.rb', line 14 def read_int_data data = handle.read(4) raise CSstats::Error, 'Cannot read int data.' unless data data.unpack('V').first end |
#read_short_data ⇒ Object
Internal: Get the 16bit integer from file.
Returns the Integer.
24 25 26 27 28 29 |
# File 'lib/csstats/parser/file_reader/handler.rb', line 24 def read_short_data data = handle.read(2) raise CSstats::Error, 'Cannot read short data.' unless data data.unpack('v').first end |
#read_string_data(length) ⇒ Object
Internal: Get the String from file.
length - The Integer length of string to read.
Returns the String.
36 37 38 39 40 41 |
# File 'lib/csstats/parser/file_reader/handler.rb', line 36 def read_string_data(length) data = handle.read(length) raise CSstats::Error, 'Cannot read string data.' unless data data.strip end |