Class: Zip::ZipExtraField::Generic
- Inherits:
-
Object
- Object
- Zip::ZipExtraField::Generic
- Defined in:
- lib/zip/zip_extra_field.rb
Overview
Meta class for extra fields
Direct Known Subclasses
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initial_parse(binstr) ⇒ Object
return field [size, content] or false.
- #to_c_dir_bin ⇒ Object
- #to_local_bin ⇒ Object
Class Method Details
.name ⇒ Object
13 14 15 |
# File 'lib/zip/zip_extra_field.rb', line 13 def self.name self.to_s.split("::")[-1] end |
.register_map ⇒ Object
7 8 9 10 11 |
# File 'lib/zip/zip_extra_field.rb', line 7 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
29 30 31 32 33 34 35 |
# File 'lib/zip/zip_extra_field.rb', line 29 def ==(other) return false if self.class != other.class each do |k, v| v != other[k] and return false end true end |
#initial_parse(binstr) ⇒ Object
return field [size, content] or false
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/zip/zip_extra_field.rb', line 18 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_bin ⇒ Object
42 43 44 45 |
# File 'lib/zip/zip_extra_field.rb', line 42 def to_c_dir_bin s = pack_for_c_dir self.class.const_get(:HEADER_ID) + [s.bytesize].pack("v") + s end |
#to_local_bin ⇒ Object
37 38 39 40 |
# File 'lib/zip/zip_extra_field.rb', line 37 def to_local_bin s = pack_for_local self.class.const_get(:HEADER_ID) + [s.bytesize].pack("v") + s end |