diff options
| author | mo khan <mo@mokhan.ca> | 2015-04-08 11:27:40 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2015-04-08 11:27:40 -0600 |
| commit | c7acbcacfc49dcc7b757b58c9eca7cb353c83cdf (patch) | |
| tree | 11f890d2e332591d5040cb537ad9f89e7b970732 | |
| parent | e0ba34decd4d88e7ce224534fafefb320bbf0bbc (diff) | |
extract attributes for svg.
| -rw-r--r-- | lib/scale/svg.rb | 25 |
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 |
