Class: ExtractTtc::InfoCommand

Inherits:
Object
  • Object
show all
Defined in:
lib/extract_ttc/commands/info.rb

Overview

Command to show detailed information about a TTC file

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ InfoCommand

Returns a new instance of InfoCommand.



8
9
10
11
# File 'lib/extract_ttc/commands/info.rb', line 8

def initialize(options = {})
  @options = options
  @verbose = options[:verbose] || false
end

Instance Method Details

#run(file_path) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/extract_ttc/commands/info.rb', line 13

def run(file_path)
  validate_file_exists(file_path)

  File.open(file_path, "rb") do |file|
    ttc = TrueTypeCollection.read(file)

    display_header_info(ttc, file_path)
    display_font_info(ttc, file) if @verbose

    0 # Success
  end
rescue ExtractTtc::ReadFileError => e
  display_error("File read error: #{e.message}")
  1
rescue ExtractTtc::InvalidFileError => e
  display_error("Invalid file: #{e.message}")
  2
rescue StandardError => e
  display_error("Error: #{e.message}")
  3
end