Class: Condenser::SVGTransformer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/condenser/transformers/svg_transformer/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(escape: nil) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/condenser/transformers/svg_transformer/base.rb', line 5

def initialize(escape: nil)
  @children = []
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



3
4
5
# File 'lib/condenser/transformers/svg_transformer/base.rb', line 3

def children
  @children
end

Instance Method Details

#to_moduleObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/condenser/transformers/svg_transformer/base.rb', line 9

def to_module()
  var_generator = Condenser::SVGTransformer::VarGenerator.new

  <<~JS
    export default function (svgAttributes) {
    #{@children.last.to_js(var_generator: var_generator)}
        if (svgAttributes) {
            Object.keys(svgAttributes).forEach(function (key) {
                __a.setAttribute(key, svgAttributes[key]);
            });
        }

        return __a;
    }
  JS
end