Class: IOWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/outputs/file_closeable.rb

Overview

wrapper class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(io) ⇒ IOWriter

Returns a new instance of IOWriter.



176
177
178
# File 'lib/logstash/outputs/file_closeable.rb', line 176

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



189
190
191
192
193
194
195
# File 'lib/logstash/outputs/file_closeable.rb', line 189

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.



196
197
198
# File 'lib/logstash/outputs/file_closeable.rb', line 196

def active
  @active
end

Instance Method Details

#flushObject



183
184
185
186
187
188
# File 'lib/logstash/outputs/file_closeable.rb', line 183

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

#write(*args) ⇒ Object



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

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