Class: Fontist::Import::Files::CollectionFile

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/import/files/collection_file.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fontisan_collection, path, name_prefix = nil) ⇒ CollectionFile

Returns a new instance of CollectionFile.



40
41
42
43
44
45
# File 'lib/fontist/import/files/collection_file.rb', line 40

def initialize(fontisan_collection, path, name_prefix = nil)
  @collection = fontisan_collection
  @path = path
  @name_prefix = name_prefix
  @fonts = extract_fonts
end

Instance Attribute Details

#fontsObject (readonly)

Returns the value of attribute fonts.



38
39
40
# File 'lib/fontist/import/files/collection_file.rb', line 38

def fonts
  @fonts
end

Class Method Details

.from_path(path, name_prefix: nil, error_collector: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fontist/import/files/collection_file.rb', line 9

def from_path(path, name_prefix: nil, error_collector: nil)
  collection = build_collection(path,
                                error_collector: error_collector)
  return nil unless collection

  new(collection, path, name_prefix)
rescue StandardError => e
  # rubocop:disable Layout/LineLength
  Fontist.ui.debug("Failed to build collection from #{File.basename(path)}: #{e.message}")
  # rubocop:enable Layout/LineLength
  nil
end

Instance Method Details

#filenameObject



47
48
49
50
51
52
# File 'lib/fontist/import/files/collection_file.rb', line 47

def filename
  # rubocop:disable Layout/LineLength
  # Use the exact filename from the archive - do NOT modify or standardize it
  # rubocop:enable Layout/LineLength
  File.basename(@path)
end

#source_filenameObject



54
55
56
57
58
# File 'lib/fontist/import/files/collection_file.rb', line 54

def source_filename
  # source_filename is only used when filename != original filename
  # Since we now use exact filename, this should always be nil
  nil
end