Class: Fontist::Font

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Font

Returns a new instance of Font.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fontist/font.rb', line 8

def initialize(options = {})
  @name = options[:name]
  @confirmation = options[:confirmation] || "no"
  @hide_licenses = options[:hide_licenses]
  @no_progress = options[:no_progress] || false
  @force = options[:force] || false
  @version = options[:version]
  @smallest = options[:smallest]
  @newest = options[:newest]
  @size_limit = options[:size_limit]
  @by_formula = options[:formula]
  @update_fontconfig = options[:update_fontconfig]

  check_or_create_fontist_path!
end

Class Method Details

.allObject



24
25
26
# File 'lib/fontist/font.rb', line 24

def self.all
  new.all
end

.find(name) ⇒ Object



28
29
30
# File 'lib/fontist/font.rb', line 28

def self.find(name)
  new(name: name).find
end

.install(name, options = {}) ⇒ Object



32
33
34
# File 'lib/fontist/font.rb', line 32

def self.install(name, options = {})
  new(options.merge(name: name)).install
end

.list(name) ⇒ Object



44
45
46
# File 'lib/fontist/font.rb', line 44

def self.list(name)
  new(name: name).list
end

.status(name) ⇒ Object



40
41
42
# File 'lib/fontist/font.rb', line 40

def self.status(name)
  new(name: name).status
end

.uninstall(name) ⇒ Object



36
37
38
# File 'lib/fontist/font.rb', line 36

def self.uninstall(name)
  new(name: name).uninstall
end

Instance Method Details

#allObject



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

def all
  all_formulas.map(&:fonts).flatten
end

#findObject



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

def find
  find_system_font || downloadable_font || manual_font ||
    raise_non_supported_font
end

#installObject



53
54
55
56
57
58
# File 'lib/fontist/font.rb', line 53

def install
  return install_formula if @by_formula

  (find_system_font unless @force) || download_font || manual_font ||
    raise_non_supported_font
end

#listObject



72
73
74
75
76
# File 'lib/fontist/font.rb', line 72

def list
  return all_list unless @name

  font_list || raise_non_supported_font
end

#statusObject



65
66
67
68
69
70
# File 'lib/fontist/font.rb', line 65

def status
  return installed_paths unless @name

  find_system_font || downloadable_font || manual_font ||
    raise_non_supported_font
end

#uninstallObject



60
61
62
63
# File 'lib/fontist/font.rb', line 60

def uninstall
  uninstall_font || downloadable_font || manual_font ||
    raise_non_supported_font
end