Class: IOWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/file.rb,
lib/logstash/outputs/google_bigquery.rb

Overview

Wrapper class that abstracts which IO being used (for instance, regular files or GzipWriter.

Inspired by lib/logstash/outputs/file.rb.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ IOWriter

Returns a new instance of IOWriter.



159
160
161
# File 'lib/logstash/outputs/file.rb', line 159

def initialize(io)
  @io = io
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object



172
173
174
175
176
177
178
# File 'lib/logstash/outputs/file.rb', line 172

def method_missing(method_name, *args, &block)
  if @io.respond_to?(method_name)
    @io.send(method_name, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#activeObject

Returns the value of attribute active.



179
180
181
# File 'lib/logstash/outputs/file.rb', line 179

def active
  @active
end

Instance Method Details

#flushObject



166
167
168
169
170
171
# File 'lib/logstash/outputs/file.rb', line 166

def flush
  @io.flush
  if @io.class == Zlib::GzipWriter
    @io.to_io.flush
  end
end

#write(*args) ⇒ Object



162
163
164
165
# File 'lib/logstash/outputs/file.rb', line 162

def write(*args)
  @io.write(*args)
  @active = true
end