Class: TestBench::Telemetry::Sink::File
- Inherits:
-
Object
- Object
- TestBench::Telemetry::Sink::File
- Includes:
- TestBench::Telemetry::Sink
- Defined in:
- lib/test_bench/telemetry/sink/file.rb
Constant Summary
Constants included from TestBench::Telemetry::Sink
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file) ⇒ File
constructor
A new instance of File.
- #receive(event_data) ⇒ Object
Constructor Details
#initialize(file) ⇒ File
Returns a new instance of File.
9 10 11 |
# File 'lib/test_bench/telemetry/sink/file.rb', line 9 def initialize(file) @file = file end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
7 8 9 |
# File 'lib/test_bench/telemetry/sink/file.rb', line 7 def file @file end |
Class Method Details
.build(file_path) ⇒ Object
13 14 15 16 17 |
# File 'lib/test_bench/telemetry/sink/file.rb', line 13 def self.build(file_path) file = ::File.open(file_path, 'w') new(file) end |
.open(file_path, &block) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/test_bench/telemetry/sink/file.rb', line 19 def self.open(file_path, &block) ::File.open(file_path, 'w') do |file| instance = new(file) block.(instance, file) return instance end end |
Instance Method Details
#receive(event_data) ⇒ Object
29 30 31 32 33 |
# File 'lib/test_bench/telemetry/sink/file.rb', line 29 def receive(event_data) text = event_data.dump file.write(text) end |