Class: PhlexIcons::Icon
- Inherits:
-
Phlex::SVG
- Object
- Phlex::SVG
- PhlexIcons::Icon
- Defined in:
- lib/phlex-icons/icon.rb
Instance Method Summary collapse
-
#initialize(name, **options) ⇒ Phlex::SVG
constructor
Factory method to create an icon component instance.
- #view_template ⇒ Object
Constructor Details
#initialize(name, **options) ⇒ Phlex::SVG
Factory method to create an icon component instance. Parses the name string, finds the corresponding class, and initializes it with options.
16 17 18 19 20 |
# File 'lib/phlex-icons/icon.rb', line 16 def initialize(name, **) @name = name @options = &.transform_keys(&:to_sym) || {} super() end |
Instance Method Details
#view_template ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/phlex-icons/icon.rb', line 22 def view_template parser = PhlexIcons::NameParser.new(@name) # Prioritize variant from the name string over options hash @options[:variant] = parser.variant_name if parser.variant_name render parser.klass.new(**@options) end |