Class: Fontist::Import::FormulaBuilder
- Inherits:
-
Object
- Object
- Fontist::Import::FormulaBuilder
- Defined in:
- lib/fontist/import/formula_builder.rb
Direct Known Subclasses
Constant Summary collapse
- FORMULA_ATTRIBUTES =
i[platforms description homepage resources font_collections fonts extract copyright license_url requires_license_agreement open_license digest command].freeze
Instance Attribute Summary collapse
-
#archive ⇒ Object
writeonly
Sets the attribute archive.
-
#extractor ⇒ Object
writeonly
Sets the attribute extractor.
-
#font_collection_files ⇒ Object
writeonly
Sets the attribute font_collection_files.
-
#font_files ⇒ Object
writeonly
Sets the attribute font_files.
-
#homepage ⇒ Object
writeonly
Sets the attribute homepage.
-
#license_text ⇒ Object
writeonly
Sets the attribute license_text.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#url ⇒ Object
writeonly
Sets the attribute url.
Instance Method Summary collapse
- #formula ⇒ Object
-
#initialize ⇒ FormulaBuilder
constructor
A new instance of FormulaBuilder.
- #name ⇒ Object
Constructor Details
#initialize ⇒ FormulaBuilder
Returns a new instance of FormulaBuilder.
21 22 23 |
# File 'lib/fontist/import/formula_builder.rb', line 21 def initialize = {} end |
Instance Attribute Details
#archive=(value) ⇒ Object (writeonly)
Sets the attribute archive
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def archive=(value) @archive = value end |
#extractor=(value) ⇒ Object (writeonly)
Sets the attribute extractor
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def extractor=(value) @extractor = value end |
#font_collection_files=(value) ⇒ Object (writeonly)
Sets the attribute font_collection_files
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def font_collection_files=(value) @font_collection_files = value end |
#font_files=(value) ⇒ Object (writeonly)
Sets the attribute font_files
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def font_files=(value) @font_files = value end |
#homepage=(value) ⇒ Object
Sets the attribute homepage
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def homepage=(value) @homepage = value end |
#license_text=(value) ⇒ Object (writeonly)
Sets the attribute license_text
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def license_text=(value) @license_text = value end |
#options=(value) ⇒ Object (writeonly)
Sets the attribute options
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def (value) = value end |
#url=(value) ⇒ Object (writeonly)
Sets the attribute url
12 13 14 |
# File 'lib/fontist/import/formula_builder.rb', line 12 def url=(value) @url = value end |
Instance Method Details
#formula ⇒ Object
25 26 27 |
# File 'lib/fontist/import/formula_builder.rb', line 25 def formula formula_attributes.map { |name| [name, send(name)] }.to_h.compact end |
#name ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fontist/import/formula_builder.rb', line 29 def name return [:name] if [:name] common = i[family_name type] .map { |attr| both_fonts.map(&attr).uniq } .map { |names| TextHelper.longest_common_prefix(names) } .map { |prefix| prefix unless prefix == "Regular" } .compact .join(" ") return common unless common.empty? both_fonts.map(&:family_name).first end |