Class: Heroicons::Icon
- Inherits:
-
Object
- Object
- Heroicons::Icon
- Defined in:
- lib/heroicons/icon.rb
Instance Method Summary collapse
-
#initialize(name:, variant:, attributes: {}) ⇒ Icon
constructor
A new instance of Icon.
- #render ⇒ Object
Constructor Details
#initialize(name:, variant:, attributes: {}) ⇒ Icon
Returns a new instance of Icon.
5 6 7 8 9 |
# File 'lib/heroicons/icon.rb', line 5 def initialize(name:, variant:, attributes: {}) @name = name @variant = variant @attributes = attributes end |
Instance Method Details
#render ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/heroicons/icon.rb', line 11 def render return if file.nil? doc = Nokogiri::XML::Document.parse(file) svg = doc.at_css("svg") @attributes.each do |k, v| svg[dasherize(k.to_s)] = v end doc.to_html.strip end |