Class: Omnizip::Converter::SevenZipToZipStrategy
- Inherits:
-
ConversionStrategy
- Object
- ConversionStrategy
- Omnizip::Converter::SevenZipToZipStrategy
- Defined in:
- lib/omnizip/converter/seven_zip_to_zip_strategy.rb
Overview
Convert 7-Zip archives to ZIP format
Instance Attribute Summary
Attributes inherited from ConversionStrategy
#options, #source_path, #target_path
Class Method Summary collapse
-
.can_convert?(source, target) ⇒ Boolean
Check if can convert.
Instance Method Summary collapse
-
#convert ⇒ ConversionResult
Perform 7z to ZIP conversion.
-
#source_format ⇒ Symbol
Get source format.
-
#target_format ⇒ Symbol
Get target format.
Methods inherited from ConversionStrategy
Constructor Details
This class inherits a constructor from Omnizip::Converter::ConversionStrategy
Class Method Details
.can_convert?(source, target) ⇒ Boolean
Check if can convert
43 44 45 |
# File 'lib/omnizip/converter/seven_zip_to_zip_strategy.rb', line 43 def self.can_convert?(source, target) source.end_with?(".7z") && target.end_with?(".zip") end |
Instance Method Details
#convert ⇒ ConversionResult
Perform 7z to ZIP conversion
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/omnizip/converter/seven_zip_to_zip_strategy.rb', line 9 def convert start_time = Time.now 0 # Open source 7z archive reader = Omnizip::Formats::SevenZip::Reader.new(source_path) reader.read # Collect entries entries_data = collect_seven_zip_entries(reader) entry_count = entries_data.size # Create target ZIP archive create_zip(entries_data) create_result(start_time, entry_count) end |
#source_format ⇒ Symbol
Get source format
29 30 31 |
# File 'lib/omnizip/converter/seven_zip_to_zip_strategy.rb', line 29 def source_format :seven_zip end |
#target_format ⇒ Symbol
Get target format
35 36 37 |
# File 'lib/omnizip/converter/seven_zip_to_zip_strategy.rb', line 35 def target_format :zip end |