Class: Omnizip::Commands::ParityRepairCommand
- Inherits:
-
Object
- Object
- Omnizip::Commands::ParityRepairCommand
- Defined in:
- lib/omnizip/commands/parity_repair_command.rb
Overview
Command to repair files using PAR2
Instance Attribute Summary collapse
-
#options ⇒ Hash
readonly
Command options.
-
#par2_file ⇒ String
readonly
PAR2 file path.
Instance Method Summary collapse
-
#initialize(par2_file, options = {}) ⇒ ParityRepairCommand
constructor
Initialize command.
-
#run ⇒ Integer
Execute command.
Constructor Details
#initialize(par2_file, options = {}) ⇒ ParityRepairCommand
Initialize command
17 18 19 20 |
# File 'lib/omnizip/commands/parity_repair_command.rb', line 17 def initialize(par2_file, = {}) @par2_file = par2_file @options = .merge() end |
Instance Attribute Details
#options ⇒ Hash (readonly)
Returns Command options.
11 12 13 |
# File 'lib/omnizip/commands/parity_repair_command.rb', line 11 def @options end |
#par2_file ⇒ String (readonly)
Returns PAR2 file path.
8 9 10 |
# File 'lib/omnizip/commands/parity_repair_command.rb', line 8 def par2_file @par2_file end |
Instance Method Details
#run ⇒ Integer
Execute command
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/omnizip/commands/parity_repair_command.rb', line 25 def run validate_inputs! puts "Repairing files with PAR2: #{File.basename(@par2_file)}" puts progress = create_progress_callback if @options[:verbose] result = Parity.repair( @par2_file, output_dir: @options[:output_dir], progress: progress, ) display_results(result) result.success? ? 0 : 1 rescue StandardError => e report_error(e) 1 end |