Class: RSpecTelemetry::Trace::Viewer::TailSource

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_telemetry/trace/viewer/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ TailSource

Returns a new instance of TailSource.



7
8
9
10
11
# File 'lib/rspec_telemetry/trace/viewer/source.rb', line 7

def initialize(path)
  @path = path
  @offset = 0
  @partial = +""
end

Instance Method Details

#drainObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/rspec_telemetry/trace/viewer/source.rb', line 13

def drain
  return [] unless File.file?(@path)

  reset_if_shrunk
  chunk = read_new_bytes
  return [] if chunk.empty?

  @partial << chunk
  split_complete_lines
end