# File 'lib/unmagic/icon.rb', line 31defconfigureyield(configuration)ifblock_given?configurationend
.find(reference) ⇒ Object
44
45
46
47
48
# File 'lib/unmagic/icon.rb', line 44deffind(reference)library_path,icon_name=parse_reference(reference)Unmagic::Icon::Library::Registry.find(library_path).find(icon_name)end
Parse a "library/name" reference into [library, name], tolerating the
emoji-style ":library/name:" decoration so both kinds share one syntax.
52
53
54
55
# File 'lib/unmagic/icon.rb', line 52defparse_reference(reference)*library_parts,name=reference.to_s.gsub(/\A:|:\z/,"").split("/")[library_parts.join("/"),name]end
Instance Method Details
#as_json ⇒ Object
77
78
79
# File 'lib/unmagic/icon.rb', line 77defas_json{name:name,svg:to_svg}end
#attributes ⇒ Object
69
70
71
# File 'lib/unmagic/icon.rb', line 69defattributesextracted_svg[:attributes]end
#contents ⇒ Object
73
74
75
# File 'lib/unmagic/icon.rb', line 73defcontentsextracted_svg[:contents].stripend
#doc ⇒ Object
65
66
67
# File 'lib/unmagic/icon.rb', line 65defdocNokogiri::XML(raw_svg_content)end
#render(options = {}) ⇒ Object
Render the asset to HTML, dispatching on its kind. SVG inlines today; a
future raster asset (png/gif) would emit an here, so callers stay
render-agnostic.
84
85
86
87
88
89
90
# File 'lib/unmagic/icon.rb', line 84defrender(options={})caseFile.extname(@path).downcasewhen".svg"thento_svg(options)elseraiseUnmagic::Icon::Error,"Don't know how to render #{@path}"endend
#to_svg(options = {}) ⇒ Object
Render the SVG with a unmagic-icon class (plus any caller class) and a
data-unmagic-icon marker. Any other options are merged verbatim as
attributes on the