Class: ExtractTtc::ExtractCommand
- Inherits:
-
Object
- Object
- ExtractTtc::ExtractCommand
- Defined in:
- lib/extract_ttc/commands/extract.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ ExtractCommand
constructor
A new instance of ExtractCommand.
- #run(file_path) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ ExtractCommand
Returns a new instance of ExtractCommand.
7 8 9 10 |
# File 'lib/extract_ttc/commands/extract.rb', line 7 def initialize( = {}) = @verbose = [:verbose] || false end |
Instance Method Details
#run(file_path) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/extract_ttc/commands/extract.rb', line 12 def run(file_path) validate_file_exists(file_path) ensure_output_directory log_verbose("Extracting fonts from #{file_path}...") output_paths = ExtractTtc.extract( file_path, output_dir: [:output_dir], ) display_results(output_paths) 0 # Success exit code rescue ExtractTtc::ReadFileError => e display_error("File read error: #{e.message}") 1 rescue ExtractTtc::InvalidFileError => e display_error("Invalid file: #{e.message}") 2 rescue ExtractTtc::WriteFileError => e display_error("Write error: #{e.message}") 3 rescue ExtractTtc::Error => e display_error("Extraction error: #{e.message}") 4 rescue RuntimeError => e # BinData errors often come as RuntimeError display_error("Invalid file: #{e.message}") 2 rescue StandardError => e display_error("Unexpected error: #{e.message}") 5 end |