Commit c7acbca

mo khan <mo@mokhan.ca>
2015-04-08 17:27:40
extract attributes for svg.
1 parent e0ba34d
Changed files (1)
lib
scale
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