IRB extended command
Namespace
Methods
- D
- E
- I
Constants
EXCB | = | ExtendCommandBundle |
IRB extended command |
||
NO_OVERRIDE | = | 0 |
OVERRIDE_PRIVATE_ONLY | = | 0x01 |
OVERRIDE_ALL | = | 0x02 |
Class Public methods
def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases)
Link
aliases = [commands_alias, flag], …
# File ../ruby/lib/irb/extend-command.rb, line 115 def self.def_extend_command(cmd_name, cmd_class, load_file = nil, *aliases) case cmd_class when Symbol cmd_class = cmd_class.id2name when String when Class cmd_class = cmd_class.name end if load_file line = __LINE__; eval %Q[ def #{cmd_name}(*opts, &b) require "#{load_file}" arity = ExtendCommand::#{cmd_class}.instance_method(:execute).arity args = (1..(arity < 0 ? ~arity : arity)).map {|i| "arg" + i.to_s } args << "*opts" if arity < 0 args << "&block" args = args.join(", ") line = __LINE__; eval %[ def #{cmd_name}(\#{args}) ExtendCommand::#{cmd_class}.execute(irb_context, \#{args}) end ], nil, __FILE__, line send :#{cmd_name}, *opts, &b end ], nil, __FILE__, line else line = __LINE__; eval %Q[ def #{cmd_name}(*opts, &b) ExtendCommand::#{cmd_class}.execute(irb_context, *opts, &b) end ], nil, __FILE__, line end for ali, flag in aliases @ALIASES.push [ali, cmd_name, flag] end end
extend_object(obj)
Link
install_extend_commands()
Link
irb_original_method_name(method_name)
Link
Instance Public methods
install_alias_method(to, from, override = NO_OVERRIDE)
Link
override = {NO_OVERRIDE, OVERRIDE_PRIVATE_ONLY, OVERRIDE_ALL}
# File ../ruby/lib/irb/extend-command.rb, line 155 def install_alias_method(to, from, override = NO_OVERRIDE) to = to.id2name unless to.kind_of?(String) from = from.id2name unless from.kind_of?(String) if override == OVERRIDE_ALL or (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or (override == NO_OVERRIDE) && !respond_to?(to, true) target = self (class << self; self; end).instance_eval{ if target.respond_to?(to, true) && !target.respond_to?(EXCB.irb_original_method_name(to), true) alias_method(EXCB.irb_original_method_name(to), to) end alias_method to, from } else print "irb: warn: can't alias #{to} from #{from}.\n" end end
irb_context()
Link
irb_exit(ret = 0)
Link
irb_load(*opts, &b)
Link