Sha256: 882da635c3958282ecab8d89662d9ac64bf6b540ff27b5c4a594e88f48f020f6
Contents?: true
Size: 1.52 KB
Versions: 6
Compression:
Stored size: 1.52 KB
Contents
module PryMoves::Helpers extend self # @return [String] Signature for the method object in Class#method format. def method_signature_with_owner(binding) meth = binding.eval('__method__') meth_obj = meth ? Pry::Method.from_binding(binding) : nil if !meth_obj "" elsif meth_obj.undefined? "#{meth_obj.name_with_owner}(UNKNOWN) (undefined method)" else args = meth_obj.parameters.inject([]) do |arr, (type, name)| name ||= (type == :block ? 'block' : "arg#{arr.size + 1}") arr << case type when :req then name.to_s when :opt then "#{name}=?" when :rest then "*#{name}" when :block then "&#{name}" else '?' end end "#{meth_obj.name_with_owner}(#{args.join(', ')})" end end def method_signature(binding) meth = binding.eval('__method__') meth_obj = meth ? Pry::Method.from_binding(binding) : nil if !meth_obj "" elsif meth_obj.undefined? "#{meth_obj.name}(UNKNOWN) (undefined method)" else args = meth_obj.parameters.inject([]) do |arr, (type, name)| name ||= (type == :block ? 'block' : "arg#{arr.size + 1}") arr << case type when :req then name.to_s when :opt then "#{name}=?" when :rest then "*#{name}" when :block then "&#{name}" else '?' end end "#{meth_obj.name}(#{args.join(', ')})" end end end
Version data entries
6 entries across 6 versions & 1 rubygems