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[name platforms description homepage resources
font_collections fonts extract copyright
license_url requires_license_agreement
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
23
24
# File 'lib/fontist/import/formula_builder.rb', line 20

def initialize
  @options = {}
  @font_files = []
  @font_collection_files = []
end

Instance Attribute Details

#font_collection_files=(value) ⇒ Object (writeonly)

Sets the attribute font_collection_files

Parameters:

  • value

    the value to set the attribute font_collection_files to.



13
14
15
# File 'lib/fontist/import/formula_builder.rb', line 13

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.



13
14
15
# File 'lib/fontist/import/formula_builder.rb', line 13

def font_files=(value)
  @font_files = value
end

#license_text=(value) ⇒ Object (writeonly)

Sets the attribute license_text

Parameters:

  • value

    the value to set the attribute license_text to.



13
14
15
# File 'lib/fontist/import/formula_builder.rb', line 13

def license_text=(value)
  @license_text = value
end

#operations=(value) ⇒ Object (writeonly)

Sets the attribute operations

Parameters:

  • value

    the value to set the attribute operations to.



13
14
15
# File 'lib/fontist/import/formula_builder.rb', line 13

def operations=(value)
  @operations = value
end

#options=(value) ⇒ Object (writeonly)

Sets the attribute options

Parameters:

  • value

    the value to set the attribute options to.



13
14
15
# File 'lib/fontist/import/formula_builder.rb', line 13

def options=(value)
  @options = value
end

#resources=(value) ⇒ Object

Sets the attribute resources

Parameters:

  • value

    the value to set the attribute resources to.



13
14
15
# File 'lib/fontist/import/formula_builder.rb', line 13

def resources=(value)
  @resources = value
end

Instance Method Details

#formulaObject



26
27
28
# File 'lib/fontist/import/formula_builder.rb', line 26

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

#saveObject



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

def save
  path = vacant_path
  yaml = YAML.dump(Helpers::HashHelper.stringify_keys(formula))
  File.write(path, yaml)
  path
end