Created
November 25, 2012 06:43
-
-
Save cmhobbs/4142659 to your computer and use it in GitHub Desktop.
Path Macro Maker for TinyFugue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
def path_maker(name, path) | |
input_array = path.split | |
defstring = "/def #{name} = " | |
path = [] | |
input_array.each do |step| | |
if step[0].match(/\d/) | |
s = split_step(step) | |
s[0].times { path << s[1] } | |
else | |
path << step | |
end | |
end | |
return defstring + path.join("%;") | |
end | |
def split_step(step) | |
return [step.match(/\d+/)[0..-1][0].to_i, step.split(/\d/)[-1]] | |
end | |
puts path_maker(ARGV[0], ARGV[1]) |
Fixed to account for an arbitrary multiplier for a given step.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Just found a bug where the script doesn't account for path numbers larger than 9 (for example, 12w would mangle the path). Fix incoming.