module PryMoves::Helpers
Constants
- PATH_TRASH
Public Instance Methods
method_signature(binding)
click to toggle source
# File lib/pry-moves/helpers.rb, line 28 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
method_signature_with_owner(binding)
click to toggle source
@return [String] Signature for the method object in Class#method format.
# File lib/pry-moves/helpers.rb, line 6 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
shorten_path(path)
click to toggle source
# File lib/pry-moves/helpers.rb, line 52 def shorten_path(path) path.gsub( /^#{PATH_TRASH}\//, '') end