Class: SFSymbolConverter
- Inherits:
-
Object
- Object
- SFSymbolConverter
- Defined in:
- lib/sf_symbol_converter/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
-
#icon_svg ⇒ Object
readonly
Returns the value of attribute icon_svg.
-
#icon_validator ⇒ Object
readonly
Returns the value of attribute icon_validator.
-
#template_svg ⇒ Object
Returns the value of attribute template_svg.
-
#template_validator ⇒ Object
readonly
Returns the value of attribute template_validator.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(template_svg, icon_svg) ⇒ SFSymbolConverter
constructor
A new instance of SFSymbolConverter.
Constructor Details
#initialize(template_svg, icon_svg) ⇒ SFSymbolConverter
Returns a new instance of SFSymbolConverter.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/sf_symbol_converter/converter.rb', line 19 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_svg ⇒ Object (readonly)
Returns the value of attribute icon_svg.
17 18 19 |
# File 'lib/sf_symbol_converter/converter.rb', line 17 def icon_svg @icon_svg end |
#icon_validator ⇒ Object (readonly)
Returns the value of attribute icon_validator.
17 18 19 |
# File 'lib/sf_symbol_converter/converter.rb', line 17 def icon_validator @icon_validator end |
#template_svg ⇒ Object
Returns the value of attribute template_svg.
16 17 18 |
# File 'lib/sf_symbol_converter/converter.rb', line 16 def template_svg @template_svg end |
#template_validator ⇒ Object (readonly)
Returns the value of attribute template_validator.
17 18 19 |
# File 'lib/sf_symbol_converter/converter.rb', line 17 def template_validator @template_validator end |
Instance Method Details
#convert ⇒ Object
32 33 34 35 36 37 |
# File 'lib/sf_symbol_converter/converter.rb', line 32 def convert @template_svg = @template_trimmer.trim(template_svg) replace_template_symbols_with_source_icons adjust_guidelines @template_svg end |