Skip to content

Instantly share code, notes, and snippets.

@cmhobbs
Created November 25, 2012 06:43
Show Gist options
  • Save cmhobbs/4142659 to your computer and use it in GitHub Desktop.
Save cmhobbs/4142659 to your computer and use it in GitHub Desktop.
Path Macro Maker for TinyFugue
#!/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])
@cmhobbs
Copy link
Author

cmhobbs commented Nov 25, 2012

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.

@cmhobbs
Copy link
Author

cmhobbs commented Nov 25, 2012

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