Class: Covet::LogFileIndex
- Inherits:
-
Object
- Object
- Covet::LogFileIndex
- Defined in:
- lib/covet/log_file.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #add_index(offset, bytes_written) ⇒ Object
- #finish! ⇒ Object
-
#initialize(options = {}) ⇒ LogFileIndex
constructor
A new instance of LogFileIndex.
- #reload!(mode) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ LogFileIndex
Returns a new instance of LogFileIndex.
135 136 137 138 |
# File 'lib/covet/log_file.rb', line 135 def initialize( = {}) @name = [:filename] || File.join(Dir.pwd, 'run_log_index.json') @index = [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
133 134 135 |
# File 'lib/covet/log_file.rb', line 133 def name @name end |
Instance Method Details
#add_index(offset, bytes_written) ⇒ Object
140 141 142 |
# File 'lib/covet/log_file.rb', line 140 def add_index(offset, bytes_written) @index << [offset, bytes_written] end |
#finish! ⇒ Object
144 145 146 147 148 149 |
# File 'lib/covet/log_file.rb', line 144 def finish! if @index.size > 0 file.write(JSON.dump(@index)) file.close end end |
#reload!(mode) ⇒ Object
151 152 153 154 155 156 |
# File 'lib/covet/log_file.rb', line 151 def reload!(mode) if @file && !@file.closed? @file.close end @file = File.open(@name, mode) end |