Class: Fontico::Emitters::Sprite

Inherits:
Object
  • Object
show all
Defined in:
lib/fontico/emitters/sprite.rb

Overview

One of definitions, referenced with . Pure Ruby string assembly: no external toolchain, builds anywhere.

Instance Method Summary collapse

Constructor Details

#initialize(manifest, build) ⇒ Sprite

Returns a new instance of Sprite.



8
9
10
11
# File 'lib/fontico/emitters/sprite.rb', line 8

def initialize(manifest, build)
  @manifest = manifest
  @build = build
end

Instance Method Details

#accepts?(_icon) ⇒ Boolean

Returns:

  • (Boolean)


13
# File 'lib/fontico/emitters/sprite.rb', line 13

def accepts?(_icon) = true

#call ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fontico/emitters/sprite.rb', line 16

def call
  symbols = @build.map do |icon, body|
    %(<symbol id="#{icon.key}" viewBox="0 0 #{@manifest.size} #{@manifest.size}" ) +
      %(fill="none">#{body}</symbol>)
  end

  "    <svg xmlns=\"http://www.w3.org/2000/svg\" aria-hidden=\"true\" style=\"display:none\">\n    \#{symbols.join(\"\\n\")}\n    </svg>\n  SVG\nend\n"

#rules_only? ⇒ Boolean

Returns:

  • (Boolean)


14
# File 'lib/fontico/emitters/sprite.rb', line 14

def rules_only? = false