lib/SVGElements/Path.rb
def parse_path(d)
			parsed = ''
			while (off = (d =~ /[A-Za-z]/))
				command = d[off]
				d.slice!(0..off)
				if @@command_arities.has_key? command.upcase.to_sym
					arity = @@command_arities[command.upcase.to_sym]
					arity = [arity] unless arity.is_a? Array
					args = arity.map do |n|
						nums = []
						n.times do |i|
							off = (d =~ /[-0-9]+/)
							off += ($~[0].length-1)
							d.slice!(0..off)
							nums << $~[0]
						end
						nums
					end
					parsed += " #{command} #{args.map{|s| s.join(' ')}.join(', ')}"
				end
			end
			return parsed.slice(1..-1) #cut off initial space
		end
#RVG allows paths to be specified that aren't actually quite
#standard, but manages to interpret them. Thus we'll do that too
RVG allows paths to be specified that aren't actually quite
standard, but manages to interpret them. Thus we'll do that too
RVG allows paths to be specified that aren ' t actually quite standard but manages to interpret them . Thus we ' ll do that too
def parse_path(d)
			parsed = ''
			while (off = (d =~ /[A-Za-z]/))
				command = d[off]
				d.slice!(0..off)
				if @@command_arities.has_key? command.upcase.to_sym
					arity = @@command_arities[command.upcase.to_sym]
					arity = [arity] unless arity.is_a? Array
					args = arity.map do |n|
						nums = []
						n.times do |i|
							off = (d =~ /[-0-9]+/)
							off += ($~[0].length-1)
							d.slice!(0..off)
							nums << $~[0]
						end
						nums
					end
					parsed += " #{command} #{args.map{|s| s.join(' ')}.join(', ')}"
				end
			end
			return parsed.slice(1..-1) 
		end
def parse_path ( d ) parsed = '' while ( off = ( d =~ / [A-Za-z] / ) ) command = d [ off ] d . slice! ( 0 .. off ) if @@command_arities . has_key? command . upcase . to_sym arity = @@command_arities [ command . upcase . to_sym ] arity = [ arity ] unless arity . is_a? Array args = arity . map do | n | nums = [ ] n . times do | i | off = ( d =~ / [-0-9]+ / ) off += ( $~ [ 0 ] . length - 1 ) d . slice! ( 0 .. off ) nums << $~ [ 0 ] end nums end parsed += " #{command} #{args.map{|s| s.join(' ')}.join(', ')}" end end return parsed . slice ( 1 .. - 1 ) end
RVG allows paths to be specified that aren't actually quite
standard, but manages to interpret them.
RVG allows paths to be specified that aren ' t actually quite standard but manages to interpret them .
#cut off initial space
d