blob: aa1ae451f7f844c797553cba9af2853efa90c9c5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
require 'nokogiri'
module Scale
class SVG
attr_accessor :width, :height
def initialize(width: nil, height: nil)
@width, @height = width, height
end
def to_xml
builder = Nokogiri::XML::Builder.new do |xml|
xml.svg(attributes) do
end
end
builder.to_xml
end
private
def attributes
attributes = {
version: "1.1",
baseProfile: "full",
xmlns: "http://www.w3.org/2000/svg",
}
attributes[:width] = width unless width.nil?
attributes[:height] = height unless height.nil?
attributes
end
end
end
|