Class: Rant::Archive::Rubyzip::ZipExtraField::Generic

Inherits:
Object
  • Object
show all
Defined in:
lib/rant/archive/rubyzip.rb

Overview

Meta class for extra fields

Direct Known Subclasses

IUnix, UniversalTime

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nameObject



1367
1368
1369
# File 'lib/rant/archive/rubyzip.rb', line 1367

def self.name
  self.to_s.split("::")[-1]
end

.register_mapObject



1361
1362
1363
1364
1365
# File 'lib/rant/archive/rubyzip.rb', line 1361

def self.register_map
  if self.const_defined?(:HEADER_ID)
    ID_MAP[self.const_get(:HEADER_ID)] = self
  end
end

Instance Method Details

#==(other) ⇒ Object



1383
1384
1385
1386
1387
1388
1389
# File 'lib/rant/archive/rubyzip.rb', line 1383

def ==(other)
  self.class != other.class and return false
  each { |k, v|
    v != other[k] and return false
  }
  true
end

#initial_parse(binstr) ⇒ Object

return field [size, content] or false



1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
# File 'lib/rant/archive/rubyzip.rb', line 1372

def initial_parse(binstr)
  if ! binstr
    # If nil, start with empty.
    return false
  elsif binstr[0,2] != self.class.const_get(:HEADER_ID)
    $stderr.puts "Warning: weired extra feild header ID. skip parsing"
    return false
  end
  [binstr[2,2].unpack("v")[0], binstr[4..-1]]
end

#to_c_dir_binObject



1396
1397
1398
1399
# File 'lib/rant/archive/rubyzip.rb', line 1396

def to_c_dir_bin
  s = pack_for_c_dir
  self.class.const_get(:HEADER_ID) + [s.length].pack("v") + s
end

#to_local_binObject



1391
1392
1393
1394
# File 'lib/rant/archive/rubyzip.rb', line 1391

def to_local_bin
  s = pack_for_local
  self.class.const_get(:HEADER_ID) + [s.length].pack("v") + s
end