class Fontist::Import::Files::CollectionFile
Attributes
fonts[R]
Public Class Methods
new(path)
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 11 def initialize(path) @path = path @fonts = read @extension = detect_extension end
Public Instance Methods
filename()
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 17 def filename File.basename(@path, ".*") + "." + @extension end
source_filename()
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 21 def source_filename File.basename(@path) unless filename == File.basename(@path) end
Private Instance Methods
detect_extension()
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 50 def detect_extension base_extension = "ttc" file_extension = File.extname(File.basename(@path)).sub(/^\./, "") return file_extension if file_extension.casecmp?(base_extension) base_extension end
extract_ttfs(tmp_dir)
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 43 def extract_ttfs(tmp_dir) filenames = ExtractTtc.extract(@path) filenames.map do |filename| File.join(tmp_dir, filename) end end
read()
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 27 def read switch_to_temp_dir do |tmp_dir| extract_ttfs(tmp_dir).map do |path| Otf::FontFile.new(path) end end end
switch_to_temp_dir() { |tmp_dir| ... }
click to toggle source
# File lib/fontist/import/files/collection_file.rb, line 35 def switch_to_temp_dir Dir.mktmpdir do |tmp_dir| Dir.chdir(tmp_dir) do yield tmp_dir end end end