Class: PhlexIcons::NameParser

Inherits:
Object
  • Object
show all
Defined in:
lib/phlex-icons/name_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(identifier) ⇒ NameParser

Initializes the parser with the full icon identifier string (e.g., “hero/arrow-right:solid”). Parses the string into pack, icon, and variant components. Determines and validates the corresponding icon component class.

Parameters:

  • identifier (String)

    The full icon identifier.

Raises:

  • (ArgumentError)

    If the name format is invalid or default pack is missing.

  • (NameError)

    If the corresponding icon class cannot be found.



13
14
15
16
17
# File 'lib/phlex-icons/name_parser.rb', line 13

def initialize(identifier)
  @identifier = identifier.to_s
  @pack_name, @icon_name, @variant_name = parse(@identifier)
  @klass = find_icon_class(@pack_name, @icon_name)
end

Instance Attribute Details

#icon_nameObject (readonly)

Returns the value of attribute icon_name.



5
6
7
# File 'lib/phlex-icons/name_parser.rb', line 5

def icon_name
  @icon_name
end

#identifierObject (readonly)

Returns the value of attribute identifier.



5
6
7
# File 'lib/phlex-icons/name_parser.rb', line 5

def identifier
  @identifier
end

#klassObject (readonly)

Returns the value of attribute klass.



5
6
7
# File 'lib/phlex-icons/name_parser.rb', line 5

def klass
  @klass
end

#pack_nameObject (readonly)

Returns the value of attribute pack_name.



5
6
7
# File 'lib/phlex-icons/name_parser.rb', line 5

def pack_name
  @pack_name
end

#variant_nameObject (readonly)

Returns the value of attribute variant_name.



5
6
7
# File 'lib/phlex-icons/name_parser.rb', line 5

def variant_name
  @variant_name
end