Class: LucideRuby::Icon
- Inherits:
-
Object
- Object
- LucideRuby::Icon
- Defined in:
- lib/lucide_ruby/icon.rb
Constant Summary collapse
- SVG_CONTENT_REGEX =
/<svg[^>]*>(.*)<\/svg>/m
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, **options) ⇒ Icon
constructor
A new instance of Icon.
- #render ⇒ Object
Constructor Details
#initialize(name, **options) ⇒ Icon
9 10 11 12 |
# File 'lib/lucide_ruby/icon.rb', line 9 def initialize(name, **) @name = self.class.normalize_name(name) = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/lucide_ruby/icon.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/lucide_ruby/icon.rb', line 7 def end |
Class Method Details
.extract_inner_html(svg_content) ⇒ Object
24 25 26 27 |
# File 'lib/lucide_ruby/icon.rb', line 24 def self.extract_inner_html(svg_content) match = svg_content.match(SVG_CONTENT_REGEX) match ? match[1].strip : "" end |
.normalize_name(name) ⇒ Object
20 21 22 |
# File 'lib/lucide_ruby/icon.rb', line 20 def self.normalize_name(name) name.to_s.strip.downcase.tr("_", "-") end |
Instance Method Details
#render ⇒ Object
14 15 16 17 18 |
# File 'lib/lucide_ruby/icon.rb', line 14 def render inner_html = load_inner_html attributes = svg_attributes build_svg(inner_html, attributes) end |