Class: Omnizip::Formats::Rar::Models::RarArchive

Inherits:
Object
  • Object
show all
Defined in:
lib/omnizip/formats/rar/models/rar_archive.rb

Overview

Represents a RAR archive with metadata

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ RarArchive

Initialize RAR archive

Parameters:

  • path (String)

    Path to RAR archive



17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 17

def initialize(path)
  @path = path
  @version = nil
  @flags = 0
  @volumes = []
  @entries = []
  @total_size = 0
  @compressed_size = 0
  @is_multi_volume = false
  @comment = nil
  @has_recovery = false
  @recovery_percent = 0
  @recovery_files = []
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def comment
  @comment
end

#compressed_sizeObject

Returns the value of attribute compressed_size.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def compressed_size
  @compressed_size
end

#entriesObject

Returns the value of attribute entries.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def entries
  @entries
end

#flagsObject

Returns the value of attribute flags.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def flags
  @flags
end

#has_recoveryObject

Returns the value of attribute has_recovery.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def has_recovery
  @has_recovery
end

#is_multi_volumeObject

Returns the value of attribute is_multi_volume.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def is_multi_volume
  @is_multi_volume
end

#pathObject

Returns the value of attribute path.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def path
  @path
end

#recovery_filesObject

Returns the value of attribute recovery_files.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def recovery_files
  @recovery_files
end

#recovery_percentObject

Returns the value of attribute recovery_percent.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def recovery_percent
  @recovery_percent
end

#total_sizeObject

Returns the value of attribute total_size.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def total_size
  @total_size
end

#versionObject

Returns the value of attribute version.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def version
  @version
end

#volumesObject

Returns the value of attribute volumes.



9
10
11
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 9

def volumes
  @volumes
end

Instance Method Details

#entry_countInteger

Get total number of entries

Returns:

  • (Integer)

    Number of entries



70
71
72
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 70

def entry_count
  @entries.size
end

#format_versionString

Get RAR format version string

Returns:

  • (String)

    Version string (RAR4 or RAR5)



63
64
65
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 63

def format_version
  @version == 5 ? "RAR5" : "RAR4"
end

#has_recovery_records?Boolean

Check if archive has recovery records

Returns:

  • (Boolean)

    true if recovery available



35
36
37
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 35

def has_recovery_records?
  @has_recovery || @recovery_files.any?
end

#multi_volume?Boolean

Check if archive is multi-volume

Returns:

  • (Boolean)

    true if multi-volume archive



49
50
51
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 49

def multi_volume?
  @is_multi_volume
end

#recovery_file_pathsArray<String>

Get recovery file paths

Returns:

  • (Array<String>)

    Paths to .rev files



42
43
44
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 42

def recovery_file_paths
  @recovery_files
end

#total_volumesInteger

Get total number of volumes

Returns:

  • (Integer)

    Number of volumes



56
57
58
# File 'lib/omnizip/formats/rar/models/rar_archive.rb', line 56

def total_volumes
  @volumes.size
end