Class: Omnizip::Commands::DecompressCommand
- Inherits:
-
Object
- Object
- Omnizip::Commands::DecompressCommand
- Defined in:
- lib/omnizip/commands/decompress_command.rb
Overview
Command to decompress files using specified algorithm.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ DecompressCommand
constructor
Initialize decompress command with options.
-
#run(input_file, output_file) ⇒ void
Execute the decompress command.
Constructor Details
#initialize(options = {}) ⇒ DecompressCommand
Initialize decompress command with options.
28 29 30 |
# File 'lib/omnizip/commands/decompress_command.rb', line 28 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
23 24 25 |
# File 'lib/omnizip/commands/decompress_command.rb', line 23 def @options end |
Instance Method Details
#run(input_file, output_file) ⇒ void
This method returns an undefined value.
Execute the decompress command.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/omnizip/commands/decompress_command.rb', line 37 def run(input_file, output_file) validate_inputs(input_file, output_file) algorithm_name = [:algorithm] || detect_algorithm verbose = [:verbose] || false CliOutputFormatter.verbose_puts( "Decompressing #{input_file} to #{output_file}...", verbose, ) CliOutputFormatter.verbose_puts( "Algorithm: #{algorithm_name}", verbose, ) start_time = Time.now decompress_file(input_file, output_file, algorithm_name) elapsed = Time.now - start_time input_size = File.size(input_file) output_size = File.size(output_file) if verbose puts "" puts CliOutputFormatter.format_compression_stats( output_size, input_size, elapsed, ) else puts "Decompressed: #{input_file} -> #{output_file}" end end |