Class: Ronin::Support::Archive::Zip::Reader::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/ronin/support/archive/zip/reader/entry.rb

Overview

Represents an entry in a zip archive.

Since:

  • 1.0.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reader, length:, method:, size:, compression:, date:, time:, crc32:, name:) ⇒ Entry

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes the zip archive entry.

Parameters:

Since:

  • 1.0.0



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 97

def initialize(reader, length: ,
                       method: ,
                       size:   ,
                       compression: ,
                       date: ,
                       time: ,
                       crc32: ,
                       name: )
  @reader      = reader
  @length      = length
  @method      = method
  @size        = size
  @compression = compression
  @date        = date
  @time        = time
  @crc32       = crc32
  @name        = name
end

Instance Attribute Details

#compressionInteger (readonly)

The compression ratio of the file.

Returns:

Since:

  • 1.0.0



52
53
54
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 52

def compression
  @compression
end

#crc32String (readonly)

The CRC32 checksum (in hex encoding).

Returns:

Since:

  • 1.0.0



67
68
69
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 67

def crc32
  @crc32
end

#dateDate (readonly)

The date of the file.

Returns:

  • (Date)

Since:

  • 1.0.0



57
58
59
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 57

def date
  @date
end

#lengthInteger (readonly)

The length of the file.

Returns:

Since:

  • 1.0.0



37
38
39
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 37

def length
  @length
end

#method:stored, :deflate (readonly)

The compression method used.

Returns:

  • (:stored, :deflate)

Since:

  • 1.0.0



42
43
44
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 42

def method
  @method
end

#nameString (readonly)

The name of the file.

Returns:

Since:

  • 1.0.0



72
73
74
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 72

def name
  @name
end

#sizeInteger (readonly)

The size of the file.

Returns:

Since:

  • 1.0.0



47
48
49
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 47

def size
  @size
end

#timeTime (readonly)

The time of the file.

Returns:

  • (Time)

Since:

  • 1.0.0



62
63
64
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 62

def time
  @time
end

Instance Method Details

#read(length = nil) ⇒ String

Reads the contents of the entry.

Parameters:

  • length (Integer, nil) (defaults to: nil)

    Optional number of bytes to read.

Returns:

Since:

  • 1.0.0



125
126
127
# File 'lib/ronin/support/archive/zip/reader/entry.rb', line 125

def read(length=nil)
  @reader.read(@name, length: length)
end