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

Methods

Public Instance methods

[Source]

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

[Source]

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

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

[Source]

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

[Validate]