Class: Fontist::Manifest::Locations

Inherits:
Object
  • Object
show all
Defined in:
lib/fontist/manifest/locations.rb

Direct Known Subclasses

Install

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(manifest) ⇒ Locations

Returns a new instance of Locations.



4
5
6
7
8
# File 'lib/fontist/manifest/locations.rb', line 4

def initialize(manifest)
  Fontist.ui.debug("Manifest: #{manifest}")

  @manifest = manifest
end

Class Method Details

.from_file(file, **keywords) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/fontist/manifest/locations.rb', line 10

def self.from_file(file, **keywords)
  raise Fontist::Errors::ManifestCouldNotBeFoundError unless File.exist?(file)

  manifest = YAML.load_file(file)
  raise Fontist::Errors::ManifestCouldNotBeReadError unless manifest.is_a?(Hash)

  from_hash(manifest, **keywords)
end

.from_hash(manifest, **keywords) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/fontist/manifest/locations.rb', line 19

def self.from_hash(manifest, **keywords)
  if keywords.empty?
    new(manifest).call
  else
    new(manifest, **keywords).call
  end
end

Instance Method Details

#callObject



27
28
29
# File 'lib/fontist/manifest/locations.rb', line 27

def call
  font_names.zip(font_paths).to_h
end