Class: Zip64::LocalFileHeader

Inherits:
Block
  • Object
show all
Defined in:
lib/zip64/structures.rb

Constant Summary collapse

SIG =
0x04034b50

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Block

base_size, #describe, #fields, fields, #initialize, #pack_field, #read_field_from, read_from, #size, size_of, #size_of

Constructor Details

This class inherits a constructor from Block

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



189
190
191
# File 'lib/zip64/structures.rb', line 189

def filename
  @filename
end

Instance Method Details

#extra_fieldObject



211
212
213
# File 'lib/zip64/structures.rb', line 211

def extra_field
  (@extra_field ||= [])
end

#extra_field=(str) ⇒ Object



203
204
205
206
207
208
209
210
# File 'lib/zip64/structures.rb', line 203

def extra_field=(str)
  case str
  when Array
    @extra_field = str
  else
    @extra_field = [str]
  end
end

#extra_field_strObject



214
215
216
217
218
219
220
221
222
223
224
# File 'lib/zip64/structures.rb', line 214

def extra_field_str
  buf = ''.zip64_force_encoding('ASCII-8BIT')
  extra_field.each do |field|
    if field.respond_to?(:to_string)
      buf << field.to_string.zip64_force_encoding('ASCII-8BIT')
    else
      buf << field.to_s.zip64_force_encoding('ASCII-8BIT')
    end
  end
  buf
end

#to_sObject



195
196
197
# File 'lib/zip64/structures.rb', line 195

def to_s
  to_string
end

#to_stringObject



190
191
192
193
194
# File 'lib/zip64/structures.rb', line 190

def to_string
  extra = extra_field_str
  self.extra_field_len = extra.size
  super + "#{@filename}#{extra}"
end

#versionObject



185
186
187
# File 'lib/zip64/structures.rb', line 185

def version
  zip64? ? 45 : 10
end

#zip64?Boolean



181
182
183
# File 'lib/zip64/structures.rb', line 181

def zip64?
  data_len == LEN64 && raw_data_len == LEN64
end