Class: Omnizip::Converter::ZipToSevenZipStrategy
- Inherits:
-
ConversionStrategy
- Object
- ConversionStrategy
- Omnizip::Converter::ZipToSevenZipStrategy
- Defined in:
- lib/omnizip/converter/zip_to_seven_zip_strategy.rb
Overview
Convert ZIP archives to 7-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 ZIP to 7z 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
42 43 44 |
# File 'lib/omnizip/converter/zip_to_seven_zip_strategy.rb', line 42 def self.can_convert?(source, target) source.end_with?(".zip") && target.end_with?(".7z") end |
Instance Method Details
#convert ⇒ ConversionResult
Perform ZIP to 7z conversion
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/omnizip/converter/zip_to_seven_zip_strategy.rb', line 9 def convert start_time = Time.now entry_count = 0 # Open source ZIP archive Omnizip::Zip::File.open(source_path) do |zip| # Collect all entries and their data entries_data = collect_entries(zip) entry_count = entries_data.size # Create target 7z archive create_seven_zip(entries_data) end create_result(start_time, entry_count) end |
#source_format ⇒ Symbol
Get source format
28 29 30 |
# File 'lib/omnizip/converter/zip_to_seven_zip_strategy.rb', line 28 def source_format :zip end |
#target_format ⇒ Symbol
Get target format
34 35 36 |
# File 'lib/omnizip/converter/zip_to_seven_zip_strategy.rb', line 34 def target_format :seven_zip end |