Class: Zip::ZipExtraField::Generic

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

Overview

Meta class for extra fields

Direct Known Subclasses

IUnix, UniversalTime

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.nameObject



1650
1651
1652
# File 'lib/zip/zip.rb', line 1650

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

.register_mapObject



1644
1645
1646
1647
1648
# File 'lib/zip/zip.rb', line 1644

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



1666
1667
1668
1669
1670
1671
1672
# File 'lib/zip/zip.rb', line 1666

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



1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
# File 'lib/zip/zip.rb', line 1655

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



1679
1680
1681
1682
# File 'lib/zip/zip.rb', line 1679

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



1674
1675
1676
1677
# File 'lib/zip/zip.rb', line 1674

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