lib/svgcode.rb in svgcode-0.4.0 vs lib/svgcode.rb in svgcode-0.6.0

- old
+ new

@@ -1,5 +1,6 @@ +require 'svgcode/utility' require 'svgcode/version' require 'svgcode/gcode/converter' require 'svgcode/svg/transform' require 'nokogiri' @@ -13,23 +14,27 @@ view_box = doc.xpath('/svg').first.attributes['viewBox'].value opts[:max_y] = view_box.split(/\s+/).last.to_f converter = Converter.new(opts) - doc.xpath('//path').each do |path| + doc.xpath('//path|//circle').each do |el| if opts[:comments] - ids = path.xpath('ancestor::g[@id]').collect do |t| + ids = el.xpath('ancestor::g[@id]').collect do |t| t.attributes['id'].value end converter.comment!(ids.join(' ')) end - converter.transforms = path.xpath('ancestor::g[@transform]').collect do |t| + converter.transforms = el.xpath('ancestor::g[@transform]').collect do |t| Transform.new(t.attributes['transform'].value) end - converter << path.attributes['d'].value + if el.name == 'path' + converter << el.attributes['d'].value + else + converter << el + end end converter.finish converter.to_s end