Class: Omnizip::Commands::ParityVerifyCommand
- Inherits:
-
Object
- Object
- Omnizip::Commands::ParityVerifyCommand
- Defined in:
- lib/omnizip/commands/parity_verify_command.rb
Overview
Command to verify 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 = {}) ⇒ ParityVerifyCommand
constructor
Initialize command.
-
#run ⇒ Integer
Execute command.
Constructor Details
#initialize(par2_file, options = {}) ⇒ ParityVerifyCommand
Initialize command
17 18 19 20 |
# File 'lib/omnizip/commands/parity_verify_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_verify_command.rb', line 11 def @options end |
#par2_file ⇒ String (readonly)
Returns PAR2 file path.
8 9 10 |
# File 'lib/omnizip/commands/parity_verify_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 46 |
# File 'lib/omnizip/commands/parity_verify_command.rb', line 25 def run validate_inputs! puts "Verifying files with PAR2: #{File.basename(@par2_file)}" puts result = Parity.verify(@par2_file) display_results(result) # Exit code based on results if result.all_ok? 0 elsif result.repairable? 1 # Damage but repairable else 2 # Damage not repairable end rescue StandardError => e report_error(e) 2 end |