Class: Harbor::ZippedIO::ZipEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/harbor/zipped_io.rb

Constant Summary collapse

DEFLATED =
8
FSTYPE_UNIX =
3
LOCAL_ENTRY_SIGNATURE =
0x04034b50
CENTRAL_DIRECTORY_STATIC_HEADER_LENGTH =
46

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ ZipEntry

Returns a new instance of ZipEntry.



147
148
149
150
151
152
153
# File 'lib/harbor/zipped_io.rb', line 147

def initialize(file)
  @file = file

  @crc = 0
  @compressed_size = file.size
  @size = file.size
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



145
146
147
# File 'lib/harbor/zipped_io.rb', line 145

def comment
  @comment
end

#crcObject

Returns the value of attribute crc.



145
146
147
# File 'lib/harbor/zipped_io.rb', line 145

def crc
  @crc
end

#fileObject

Returns the value of attribute file.



145
146
147
# File 'lib/harbor/zipped_io.rb', line 145

def file
  @file
end

#nameObject

Returns the value of attribute name.



145
146
147
# File 'lib/harbor/zipped_io.rb', line 145

def name
  @name
end

#sizeObject

Returns the value of attribute size.



145
146
147
# File 'lib/harbor/zipped_io.rb', line 145

def size
  @size
end

Instance Method Details

#binary_dos_dateObject



155
156
157
# File 'lib/harbor/zipped_io.rb', line 155

def binary_dos_date
  (time.day) + (time.month << 5) + ((time.year - 1980) << 9)
end

#binary_dos_timeObject



159
160
161
# File 'lib/harbor/zipped_io.rb', line 159

def binary_dos_time
  (time.sec / 2) + (time.min << 5) + (time.hour << 11)
end

#central_directory_header_sizeObject



163
164
165
# File 'lib/harbor/zipped_io.rb', line 163

def central_directory_header_size
  CENTRAL_DIRECTORY_STATIC_HEADER_LENGTH + @file.name.size
end

#read_local_entryObject



171
172
173
174
# File 'lib/harbor/zipped_io.rb', line 171

def read_local_entry
  generate unless @data
  @data
end

#timeObject



167
168
169
# File 'lib/harbor/zipped_io.rb', line 167

def time
  Time.now
end