Class: Fontist::Import::FormulaBuilder

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

Direct Known Subclasses

ManualFormulaBuilder

Constant Summary collapse

FORMULA_ATTRIBUTES =
%i[description homepage resources
font_collections fonts extract copyright
license_url open_license digest command].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeFormulaBuilder

Returns a new instance of FormulaBuilder.



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

def initialize
  @options = {}
end

Instance Attribute Details

#archive=(value) ⇒ Object (writeonly)

Sets the attribute archive

Parameters:

  • value

    the value to set the attribute archive to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def archive=(value)
  @archive = value
end

#extractor=(value) ⇒ Object (writeonly)

Sets the attribute extractor

Parameters:

  • value

    the value to set the attribute extractor to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def extractor=(value)
  @extractor = value
end

#font_collection_files=(value) ⇒ Object (writeonly)

Sets the attribute font_collection_files

Parameters:

  • value

    the value to set the attribute font_collection_files to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def font_collection_files=(value)
  @font_collection_files = value
end

#font_files=(value) ⇒ Object (writeonly)

Sets the attribute font_files

Parameters:

  • value

    the value to set the attribute font_files to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def font_files=(value)
  @font_files = value
end

#homepage=(value) ⇒ Object

Sets the attribute homepage

Parameters:

  • value

    the value to set the attribute homepage to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def homepage=(value)
  @homepage = value
end

#license_text=(value) ⇒ Object (writeonly)

Sets the attribute license_text

Parameters:

  • value

    the value to set the attribute license_text to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def license_text=(value)
  @license_text = value
end

#options=(value) ⇒ Object (writeonly)

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def options=(value)
  @options = value
end

#url=(value) ⇒ Object (writeonly)

Sets the attribute url

Parameters:

  • value

    the value to set the attribute url to.



11
12
13
# File 'lib/fontist/import/formula_builder.rb', line 11

def url=(value)
  @url = value
end

Instance Method Details

#formulaObject



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

def formula
  formula_attributes.map { |name| [name, send(name)] }.to_h.compact
end

#nameObject



28
29
30
31
32
33
34
# File 'lib/fontist/import/formula_builder.rb', line 28

def name
  return @options[:name] if @options[:name]

  unique_names = both_fonts.map(&:family_name).uniq
  TextHelper.longest_common_prefix(unique_names) ||
    both_fonts.first.family_name
end