Class: Fontist::FontPath
- Inherits:
-
Object
- Object
- Fontist::FontPath
- Defined in:
- lib/fontist/font_path.rb
Instance Method Summary collapse
- #fontist_font? ⇒ Boolean
- #formulas ⇒ Object
-
#initialize(path) ⇒ FontPath
constructor
A new instance of FontPath.
- #to_s ⇒ Object
Constructor Details
#initialize(path) ⇒ FontPath
Returns a new instance of FontPath.
3 4 5 |
# File 'lib/fontist/font_path.rb', line 3 def initialize(path) @path = path end |
Instance Method Details
#fontist_font? ⇒ Boolean
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/fontist/font_path.rb', line 23 def fontist_font? # Normalize path separators to forward slashes for comparison normalized_path = @path.gsub("\\", "/") normalized_fonts_path = Fontist.fonts_path.to_s.gsub("\\", "/") # DEBUG: Log path comparison on Windows if ENV["DEBUG_FONT_PATH"] puts "DEBUG FontPath#fontist_font?:" puts " @path: #{@path.inspect}" puts " normalized_path: #{normalized_path.inspect}" puts " Fontist.fonts_path.to_s: #{Fontist.fonts_path.to_s.inspect}" puts " normalized_fonts_path: #{normalized_fonts_path.inspect}" puts " Fontist::Utils::System.windows?: #{Fontist::Utils::System.windows?.inspect}" end # On Windows, use case-insensitive comparison; on Unix, case-sensitive result = if Fontist::Utils::System.windows? normalized_path.downcase.start_with?(normalized_fonts_path.downcase) else normalized_path.start_with?(normalized_fonts_path) end puts " result: #{result.inspect}" if ENV["DEBUG_FONT_PATH"] result end |
#formulas ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/fontist/font_path.rb', line 15 def formulas @formulas ||= if fontist_font? Indexes::FilenameIndex.from_file.load_index_formulas(File.basename(@path)).flat_map(&:name) else [] end end |
#to_s ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/fontist/font_path.rb', line 7 def to_s [].tap do |s| s << "-" s << @path s << "(from #{formulas.join(' or ')} formula)" if formulas.any? end.join(" ") end |