Code

invariants are usually clearer up front
authormental <mental@users.sourceforge.net>
Sat, 12 Aug 2006 07:10:46 +0000 (07:10 +0000)
committermental <mental@users.sourceforge.net>
Sat, 12 Aug 2006 07:10:46 +0000 (07:10 +0000)
share/extensions/simplepath.rb

index 7c634fe249b5a5892bd37b6165c0e408b51bfa4c..466a75d10faf6df068c4a0a103acf9c5fe77e002 100755 (executable)
@@ -78,7 +78,9 @@ def parsePath(d)
     lastCommand = nil
 
     lexPath(d) do |token, isCommand|
-        unless command
+        if command
+            raise 'Invalid number of parameters' if isCommand
+        else
             if isCommand
                 raise 'Invalid path, must begin with moveto.' \
                   unless lastCommand or token.upcase == 'M'
@@ -94,8 +96,6 @@ def parsePath(d)
                 end
             end
             outputCommand = command.upcase
-        else
-            raise 'Invalid number of parameters' if isCommand
         end
 
         unless isCommand