Class: Purplelight::WriterCSV::CountingIO
- Inherits:
-
Object
- Object
- Purplelight::WriterCSV::CountingIO
- Defined in:
- lib/purplelight/writer_csv.rb
Overview
Minimal wrapper to count bytes written for rotate logic when underlying compressed writer doesn't expose position (e.g., zstd-ruby).
Instance Attribute Summary collapse
-
#bytes_written ⇒ Object
readonly
Returns the value of attribute bytes_written.
Instance Method Summary collapse
-
#initialize(io) ⇒ CountingIO
constructor
A new instance of CountingIO.
- #method_missing(method_name) ⇒ Object
- #respond_to_missing?(method_name, include_private = false) ⇒ Boolean
- #write(data) ⇒ Object (also: #<<)
Constructor Details
#initialize(io) ⇒ CountingIO
Returns a new instance of CountingIO.
106 107 108 109 |
# File 'lib/purplelight/writer_csv.rb', line 106 def initialize(io) @io = io @bytes_written = 0 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name) ⇒ Object
119 120 121 |
# File 'lib/purplelight/writer_csv.rb', line 119 def method_missing(method_name, *, &) @io.send(method_name, *, &) end |
Instance Attribute Details
#bytes_written ⇒ Object (readonly)
Returns the value of attribute bytes_written.
104 105 106 |
# File 'lib/purplelight/writer_csv.rb', line 104 def bytes_written @bytes_written end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
123 124 125 |
# File 'lib/purplelight/writer_csv.rb', line 123 def respond_to_missing?(method_name, include_private = false) @io.respond_to?(method_name, include_private) end |
#write(data) ⇒ Object Also known as: <<
111 112 113 114 115 |
# File 'lib/purplelight/writer_csv.rb', line 111 def write(data) bytes_written = @io.write(data) @bytes_written += bytes_written bytes_written end |