Class: Fontist::MacosImportSource

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

Overview

Import source for macOS supplementary fonts

Tracks the specific framework version, catalog posting date, and asset ID for fonts imported from Apple’s macOS font catalogs.

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean Also known as: eql?

Equality check based on differentiation key

Parameters:

  • other (Object)

    The object to compare

Returns:

  • (Boolean)

    true if objects are equal



86
87
88
89
90
91
# File 'lib/fontist/macos_import_source.rb', line 86

def ==(other)
  return false unless other.is_a?(MacosImportSource)

  framework_version == other.framework_version &&
    asset_id&.downcase == other.asset_id&.downcase
end

#compatible_with_macos?(macos_version) ⇒ Boolean

Checks if this import source is compatible with a specific macOS version

Parameters:

  • macos_version (String)

    The macOS version to check

Returns:

  • (Boolean)

    true if compatible



56
57
58
59
# File 'lib/fontist/macos_import_source.rb', line 56

def compatible_with_macos?(macos_version)
  MacosFrameworkMetadata.compatible_with_macos?(framework_version,
                                                macos_version)
end

#descriptionString

Gets the description for this framework

Returns:

  • (String)

    The framework description



78
79
80
# File 'lib/fontist/macos_import_source.rb', line 78

def description
  MacosFrameworkMetadata.description(framework_version)
end

#differentiation_keyString?

Returns the asset ID in lowercase for consistent differentiation

Returns:

  • (String, nil)

    Lowercased asset ID or nil



20
21
22
# File 'lib/fontist/macos_import_source.rb', line 20

def differentiation_key
  asset_id&.downcase
end

#max_macos_versionString?

Gets the maximum macOS version for this framework

Returns:

  • (String, nil)

    The maximum macOS version or nil if unlimited



48
49
50
# File 'lib/fontist/macos_import_source.rb', line 48

def max_macos_version
  MacosFrameworkMetadata.max_macos_version(framework_version)
end

#min_macos_versionString?

Gets the minimum macOS version for this framework

Returns:

  • (String, nil)

    The minimum macOS version or nil



41
42
43
# File 'lib/fontist/macos_import_source.rb', line 41

def min_macos_version
  MacosFrameworkMetadata.min_macos_version(framework_version)
end

#outdated?(new_source) ⇒ Boolean

Checks if this import source is older than the provided new source

Parameters:

Returns:

  • (Boolean)

    true if this source is outdated



28
29
30
31
32
33
34
35
36
# File 'lib/fontist/macos_import_source.rb', line 28

def outdated?(new_source)
  return false unless new_source.is_a?(MacosImportSource)
  return false unless posted_date && new_source.posted_date

  Time.parse(posted_date) < Time.parse(new_source.posted_date)
rescue StandardError => e
  Fontist.ui.error("Error comparing import sources: #{e.message}")
  false
end

#parser_classString

Gets the parser class name for this framework

Returns:

  • (String)

    The fully qualified parser class name



71
72
73
# File 'lib/fontist/macos_import_source.rb', line 71

def parser_class
  MacosFrameworkMetadata.parser_class(framework_version)
end

#to_sString

Returns a human-readable string representation

Returns:

  • (String)

    String representation for debugging/logging



64
65
66
# File 'lib/fontist/macos_import_source.rb', line 64

def to_s
  "macOS Font#{framework_version} (posted: #{posted_date}, asset: #{asset_id})"
end