summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/scale/svg.rb25
1 files changed, 17 insertions, 8 deletions
diff --git a/lib/scale/svg.rb b/lib/scale/svg.rb
index 468946d..aa1ae45 100644
--- a/lib/scale/svg.rb
+++ b/lib/scale/svg.rb
@@ -4,20 +4,29 @@ 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|
- 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?
-
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