Class: Heroicons::Icon

Inherits:
Object
  • Object
show all
Defined in:
lib/heroicons/icon.rb

Instance Method Summary collapse

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

#renderObject



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