Class: LogStash::Outputs::LogstashAzureBlobOutput::TemporaryFileFactory::IOWrappedGzip

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/logstash/outputs/blob/temporary_file_factory.rb

Overview

clas for the encoding

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_io) ⇒ IOWrappedGzip

initialize the class for encoding



104
105
106
107
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 104

def initialize(file_io)
  @file_io = file_io
  @gzip_writer = Zlib::GzipWriter.open(file_io)
end

Instance Attribute Details

#file_ioObject (readonly)

Returns the value of attribute file_io.



101
102
103
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 101

def file_io
  @file_io
end

#gzip_writerObject (readonly)

Returns the value of attribute gzip_writer.



101
102
103
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 101

def gzip_writer
  @gzip_writer
end

Instance Method Details

#fsyncObject

gets the fsync



128
129
130
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 128

def fsync
  @gzip_writer.to_io.fsync
end

#pathObject

gets the path



110
111
112
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 110

def path
  @gzip_writer.to_io.path
end

#sizeObject

gets the file size



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/logstash/outputs/blob/temporary_file_factory.rb', line 115

def size
  # to get the current file size
  if @gzip_writer.pos.zero?
    # Ensure a zero file size is returned when nothing has
    # yet been written to the gzip file.
    0
  else
    @gzip_writer.flush
    @gzip_writer.to_io.size
  end
end