Class: Fontist::FontPath

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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ FontPath

Returns a new instance of FontPath.



5
6
7
# File 'lib/fontist/font_path.rb', line 5

def initialize(path)
  @path = path
end

Instance Method Details

#fontist_font?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/fontist/font_path.rb', line 25

def fontist_font?
  @path.start_with?(Fontist.fonts_path.to_s)
end

#formulasObject



17
18
19
20
21
22
23
# File 'lib/fontist/font_path.rb', line 17

def formulas
  @formulas ||= if fontist_font?
                  Indexes::FilenameIndex.from_yaml.load_index_formulas(File.basename(@path)).map(&:name)
                else
                  []
                end
end

#to_sObject



9
10
11
12
13
14
15
# File 'lib/fontist/font_path.rb', line 9

def to_s
  [].tap do |s|
    s << "-"
    s << @path
    s << "(from #{formulas.join(' or ')} formula)" if formulas.any?
  end.join(" ")
end