Class: RSpec::Risky::Probe::OutputProbe::StreamStats

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/risky/probe/output_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stream_name) ⇒ StreamStats

Returns a new instance of StreamStats.



50
51
52
53
54
55
56
# File 'lib/rspec/risky/probe/output_report.rb', line 50

def initialize(stream_name)
  @stream_name = stream_name
  @write_count = 0
  @byte_count = 0
  @first_location = nil
  @first_sample = nil
end

Instance Attribute Details

#byte_countObject (readonly)

Returns the value of attribute byte_count.



48
49
50
# File 'lib/rspec/risky/probe/output_report.rb', line 48

def byte_count
  @byte_count
end

#first_locationObject (readonly)

Returns the value of attribute first_location.



48
49
50
# File 'lib/rspec/risky/probe/output_report.rb', line 48

def first_location
  @first_location
end

#first_sampleObject (readonly)

Returns the value of attribute first_sample.



48
49
50
# File 'lib/rspec/risky/probe/output_report.rb', line 48

def first_sample
  @first_sample
end

#stream_nameObject (readonly)

Returns the value of attribute stream_name.



48
49
50
# File 'lib/rspec/risky/probe/output_report.rb', line 48

def stream_name
  @stream_name
end

#write_countObject (readonly)

Returns the value of attribute write_count.



48
49
50
# File 'lib/rspec/risky/probe/output_report.rb', line 48

def write_count
  @write_count
end

Instance Method Details

#record(data, location) ⇒ Object



58
59
60
61
62
63
# File 'lib/rspec/risky/probe/output_report.rb', line 58

def record(data, location)
  @write_count += 1
  @byte_count += data.bytesize
  @first_location ||= location
  @first_sample ||= data.byteslice(0, 200)
end

#written?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/rspec/risky/probe/output_report.rb', line 65

def written?
  write_count.positive?
end