Class: CSstats::Parser::Reader::FileReader
- Inherits:
-
Object
- Object
- CSstats::Parser::Reader::FileReader
- Defined in:
- lib/csstats/parser/reader/file_reader.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
Instance Method Summary collapse
-
#initialize(file_path, options = {}) ⇒ FileReader
constructor
A new instance of FileReader.
- #read(&block) ⇒ Object
Constructor Details
#initialize(file_path, options = {}) ⇒ FileReader
Returns a new instance of FileReader.
11 12 13 14 15 16 |
# File 'lib/csstats/parser/reader/file_reader.rb', line 11 def initialize(file_path, = {}) @file_path = file_path @limit = [:limit] || 0 raise CSstats::FileNotExist unless File.exist?(file_path.to_s) end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
9 10 11 |
# File 'lib/csstats/parser/reader/file_reader.rb', line 9 def file_path @file_path end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
9 10 11 |
# File 'lib/csstats/parser/reader/file_reader.rb', line 9 def limit @limit end |
Instance Method Details
#read(&block) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/csstats/parser/reader/file_reader.rb', line 18 def read(&block) return unless block_given? file = File.new(file_path, 'r') # Need to read first data, which means file version. _file_version = streamer(file).read_short_data read_data(file, &block) file.close end |