Class: SFSymbolConverter

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

Overview

Given a source SVG and a SFSymbol template, generate a SFSymbol

Constant Summary collapse

SOURCE_ICON_VIEWBOX_SIZE =
24
REFERENCE_SFSYMBOL_FONT_CAPS_HEIGHT =
14
TARGET_SYMBOL_HEIGHT_MEDIUM =
16
SFSYMBOL_MEDIUM_TO_SMALL_SCALE =
0.783
MARGIN_LINE_WIDTH =
0.5

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_svg, icon_svg) ⇒ SFSymbolConverter

Returns a new instance of SFSymbolConverter.



24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sf_symbol_converter.rb', line 24

def initialize(template_svg, icon_svg)
  @template_svg = template_svg
  @icon_svg = icon_svg

  @icon_validator = IconValidator.new(SOURCE_ICON_VIEWBOX_SIZE)
  @template_validator = TemplateValidator.new

  @template_trimmer = TemplateTrimmer.new

  @icon_validator.validate(icon_svg)
  @template_validator.validate(template_svg)
end

Instance Attribute Details

#icon_svgObject (readonly)

Returns the value of attribute icon_svg.



22
23
24
# File 'lib/sf_symbol_converter.rb', line 22

def icon_svg
  @icon_svg
end

#icon_validatorObject (readonly)

Returns the value of attribute icon_validator.



22
23
24
# File 'lib/sf_symbol_converter.rb', line 22

def icon_validator
  @icon_validator
end

#template_svgObject

Returns the value of attribute template_svg.



21
22
23
# File 'lib/sf_symbol_converter.rb', line 21

def template_svg
  @template_svg
end

#template_validatorObject (readonly)

Returns the value of attribute template_validator.



22
23
24
# File 'lib/sf_symbol_converter.rb', line 22

def template_validator
  @template_validator
end

Instance Method Details

#convertObject



37
38
39
40
41
42
# File 'lib/sf_symbol_converter.rb', line 37

def convert
  @template_svg = @template_trimmer.trim(template_svg)
  replace_template_symbols_with_source_icons
  adjust_guidelines
  @template_svg
end