Created
December 1, 2017 04:10
-
-
Save rickhull/00221b5a04fd9f14c1dc379150890261 to your computer and use it in GitHub Desktop.
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
def self.def_builtin_commands(delegation_class, command_specs) | |
for meth, args in command_specs | |
arg_str = args.collect{|arg| arg.downcase}.join(", ") | |
call_arg_str = args.collect{ | |
|arg| | |
case arg | |
when /^(FILENAME.*)$/ | |
format("expand_path(%s)", $1.downcase) | |
when /^(\*FILENAME.*)$/ | |
# \*FILENAME* -> filenames.collect{|fn| expand_path(fn)}.join(", ") | |
$1.downcase + '.collect{|fn| expand_path(fn)}' | |
else | |
arg | |
end | |
}.join(", ") | |
d = %Q[def #{meth}(#{arg_str}) | |
#{delegation_class}.#{meth}(#{call_arg_str}) | |
end] | |
Shell.notify "Define #{meth}(#{arg_str})", Shell.debug? | |
Shell.notify("Definition of #{meth}: ", d, | |
Shell.debug.kind_of?(Integer) && Shell.debug > 1) | |
eval d | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment