Tidy up accessors in `Entry`.
Remove a load of accessors from the 'public' API by not documenting them, and remove access to `header_signature` completely. Also, `Entry#extra` has been created to allow extra fields to be set correctly after initialization.
This commit is contained in:
parent
e4ceedaa58
commit
156b0f3dee
|
@ -6,14 +6,14 @@ module Zip
|
|||
# Language encoding flag (EFS) bit
|
||||
EFS = 0b100000000000
|
||||
|
||||
attr_accessor :comment, :compressed_size, :crc, :extra,
|
||||
:name, :size, :local_header_offset, :zipfile, :fstype, :external_file_attributes,
|
||||
:internal_file_attributes,
|
||||
:gp_flags, :header_signature, :follow_symlinks,
|
||||
:restore_times, :restore_permissions, :restore_ownership,
|
||||
:unix_uid, :unix_gid, :unix_perms,
|
||||
:dirty
|
||||
attr_reader :compression_level, :ftype, :filepath # :nodoc:
|
||||
attr_accessor :comment, :compressed_size, :follow_symlinks, :name,
|
||||
:restore_ownership, :restore_permissions, :restore_times,
|
||||
:size, :unix_gid, :unix_perms, :unix_uid, :zipfile
|
||||
|
||||
attr_accessor :crc, :dirty, :external_file_attributes, :fstype, :gp_flags,
|
||||
:internal_file_attributes, :local_header_offset # :nodoc:
|
||||
|
||||
attr_reader :extra, :compression_level, :ftype, :filepath # :nodoc:
|
||||
|
||||
def set_default_vars_values
|
||||
@local_header_offset = 0
|
||||
|
@ -89,6 +89,14 @@ module Zip
|
|||
gp_flags & 8 == 8
|
||||
end
|
||||
|
||||
def extra=(field)
|
||||
@extra = if field.nil?
|
||||
ExtraField.new
|
||||
else
|
||||
field.kind_of?(ExtraField) ? field : ExtraField.new(field.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def time
|
||||
if @extra['UniversalTime']
|
||||
@extra['UniversalTime'].mtime
|
||||
|
@ -384,7 +392,7 @@ module Zip
|
|||
end
|
||||
|
||||
def check_c_dir_entry_signature
|
||||
return if header_signature == ::Zip::CENTRAL_DIRECTORY_ENTRY_SIGNATURE
|
||||
return if @header_signature == ::Zip::CENTRAL_DIRECTORY_ENTRY_SIGNATURE
|
||||
|
||||
raise Error, "Zip local header magic not found at location '#{local_header_offset}'"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue