lib/prawn/svg/parser.rb in prawn-svg-0.9.1.11 vs lib/prawn/svg/parser.rb in prawn-svg-0.12.0.1

- old
+ new

@@ -49,11 +49,10 @@ end private REQUIRED_ATTRIBUTES = { - "line" => %w(x1 y1 x2 y2), "polyline" => %w(points), "polygon" => %w(points), "circle" => %w(r), "ellipse" => %w(rx ry), "rect" => %w(width height), @@ -86,11 +85,11 @@ when 'text' @svg_text ||= Text.new @svg_text.parse(element) when 'line' - element.add_call 'line', x(attrs['x1']), y(attrs['y1']), x(attrs['x2']), y(attrs['y2']) + element.add_call 'line', x(attrs['x1'] || '0'), y(attrs['y1'] || '0'), x(attrs['x2'] || '0'), y(attrs['y2'] || '0') when 'polyline' points = attrs['points'].split(/\s+/) return unless base_point = points.shift x, y = base_point.split(",") @@ -162,14 +161,18 @@ commands = [] @document.warnings << e.message end commands.collect do |command, args| - point_to = [x(args[0]), y(args[1])] - if command == 'curve_to' - opts = {:bounds => [[x(args[2]), y(args[3])], [x(args[4]), y(args[5])]]} + if args && args.length > 0 + point_to = [x(args[0]), y(args[1])] + if command == 'curve_to' + opts = {:bounds => [[x(args[2]), y(args[3])], [x(args[4]), y(args[5])]]} + end + element.add_call command, point_to, opts + else + element.add_call command end - element.add_call command, point_to, opts end end def parse_use(element) if href = element.attributes['xlink:href']