Class: Fontist::Font
- Inherits:
-
Object
- Object
- Fontist::Font
- Defined in:
- lib/fontist/font.rb
Class Method Summary collapse
- .all ⇒ Object
- .find(name) ⇒ Object
- .install(name, options = {}) ⇒ Object
- .install_many(names, options = {}) ⇒ Object
- .list(name) ⇒ Object
- .status(name) ⇒ Object
- .uninstall(name) ⇒ Object
Instance Method Summary collapse
- #all ⇒ Object
- #find ⇒ Object
-
#initialize(options = {}) ⇒ Font
constructor
A new instance of Font.
- #install ⇒ Object
- #list ⇒ Object
- #status ⇒ Object
- #uninstall ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Font
Returns a new instance of Font.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/fontist/font.rb', line 9 def initialize( = {}) @name = [:name] @confirmation = [:confirmation] || "no" @hide_licenses = [:hide_licenses] @no_progress = [:no_progress] || false @force = [:force] || false @version = [:version] @smallest = [:smallest] @newest = [:newest] @size_limit = [:size_limit] @by_formula = [:formula] @update_fontconfig = [:update_fontconfig] @install_location = [:location] || [:install_location] validate_location_parameter! check_or_create_fontist_path! end |
Class Method Details
.all ⇒ Object
27 28 29 |
# File 'lib/fontist/font.rb', line 27 def self.all new.all end |
.find(name) ⇒ Object
31 32 33 |
# File 'lib/fontist/font.rb', line 31 def self.find(name) new(name: name).find end |
.install(name, options = {}) ⇒ Object
35 36 37 |
# File 'lib/fontist/font.rb', line 35 def self.install(name, = {}) new(.merge(name: name)).install end |
.install_many(names, options = {}) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/fontist/font.rb', line 39 def self.install_many(names, = {}) successes = [] failures = [] names.each do |name| install(name, ) successes << name rescue Fontist::Errors::GeneralError => e failures << { font: name, error: e } end { successes: successes, failures: failures } end |
.list(name) ⇒ Object
61 62 63 |
# File 'lib/fontist/font.rb', line 61 def self.list(name) new(name: name).list end |
.status(name) ⇒ Object
57 58 59 |
# File 'lib/fontist/font.rb', line 57 def self.status(name) new(name: name).status end |
.uninstall(name) ⇒ Object
53 54 55 |
# File 'lib/fontist/font.rb', line 53 def self.uninstall(name) new(name: name).uninstall end |
Instance Method Details
#all ⇒ Object
95 96 97 |
# File 'lib/fontist/font.rb', line 95 def all all_formulas.map(&:fonts).flatten end |
#find ⇒ Object
65 66 67 68 |
# File 'lib/fontist/font.rb', line 65 def find find_system_font || downloadable_font || manual_font || raise_non_supported_font end |
#install ⇒ Object
70 71 72 73 74 75 |
# File 'lib/fontist/font.rb', line 70 def install return install_formula if @by_formula (find_system_font unless @force) || download_font || manual_font || raise_non_supported_font end |
#list ⇒ Object
89 90 91 92 93 |
# File 'lib/fontist/font.rb', line 89 def list return all_list unless @name font_list || raise_non_supported_font end |
#status ⇒ Object
82 83 84 85 86 87 |
# File 'lib/fontist/font.rb', line 82 def status return installed_paths unless @name find_system_font || downloadable_font || manual_font || raise_non_supported_font end |
#uninstall ⇒ Object
77 78 79 80 |
# File 'lib/fontist/font.rb', line 77 def uninstall uninstall_font || downloadable_font || manual_font || raise_non_supported_font end |