Module IRB::MethodExtender
In: lib/irb/extend-command.rb

Methods

Public Instance methods

[Source]

     # File lib/irb/extend-command.rb, line 241
241:     def def_post_proc(base_method, extend_method)
242:       base_method = base_method.to_s
243:       extend_method = extend_method.to_s
244: 
245:       alias_name = new_alias_name(base_method)
246:       module_eval %[
247:         alias_method alias_name, base_method
248:         def #{base_method}(*opts)
249:           send :#{alias_name}, *opts
250:           send :#{extend_method}, *opts
251:         end
252:       ]
253:     end

[Source]

     # File lib/irb/extend-command.rb, line 227
227:     def def_pre_proc(base_method, extend_method)
228:       base_method = base_method.to_s
229:       extend_method = extend_method.to_s
230: 
231:       alias_name = new_alias_name(base_method)
232:       module_eval %[
233:         alias_method alias_name, base_method
234:         def #{base_method}(*opts)
235:           send :#{extend_method}, *opts
236:           send :#{alias_name}, *opts
237:         end
238:       ]
239:     end

return #{prefix}#{name}#{postfix}<num>

[Source]

     # File lib/irb/extend-command.rb, line 256
256:     def new_alias_name(name, prefix = "__alias_of__", postfix = "__")
257:       base_name = "#{prefix}#{name}#{postfix}"
258:       all_methods = instance_methods(true) + private_instance_methods(true)
259:       same_methods = all_methods.grep(/^#{Regexp.quote(base_name)}[0-9]*$/)
260:       return base_name if same_methods.empty?
261:       no = same_methods.size
262:       while !same_methods.include?(alias_name = base_name + no)
263:         no += 1
264:       end
265:       alias_name
266:     end

[Validate]