Class: CSstats::Parser::FileReader
- Inherits:
-
Object
- Object
- CSstats::Parser::FileReader
- Defined in:
- lib/csstats/parser/file_reader.rb,
lib/csstats/parser/file_reader/handler.rb
Defined Under Namespace
Classes: Handler
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.
8 9 10 11 12 13 |
# File 'lib/csstats/parser/file_reader.rb', line 8 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.
6 7 8 |
# File 'lib/csstats/parser/file_reader.rb', line 6 def file_path @file_path end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
6 7 8 |
# File 'lib/csstats/parser/file_reader.rb', line 6 def limit @limit end |
Instance Method Details
#read(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/csstats/parser/file_reader.rb', line 15 def read(&block) return unless block_given? file = File.new(file_path, 'r') # Need to read first data, which means file version. _file_version = Handler.new(file).read_short_data read_data(file, &block) file.close end |