Class: Purplelight::WriterCSV::CountingIO

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_writtenObject (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

Returns:

  • (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