Sha256: 42a2647ead40e7182dd5f2457c943afcdb40a5d983d63211db8d49e021e0bdbf

Contents?: true

Size: 927 Bytes

Versions: 4

Compression:

Stored size: 927 Bytes

Contents

require 'debugging'

module Debugging
  private

  def howtocall(object = self, method_or_proc)
    if method_or_proc.is_a? Proc
      params = method_or_proc.parameters
      template = "call(%s)"
    else
      unless method_or_proc.is_a?(Method) || method_or_proc.is_a?(UnboundMethod)
        method_or_proc = object.method(method_or_proc)
      end
      params = method_or_proc.parameters
      template = "#{method_or_proc.name}(%s)"
    end

    sig = params.map{ |type, name|
      param = ""
      param << "*" if type == :rest
      param << "**" if type == :keyrest
      param << "&" if type == :block
      name = ?? if !name && !(type == :rest || type == :keyrest)
      if type == :opt || type == :key
        param << Paint[name, :underline]
      else
        param << name.to_s
      end
      param << ":" if type == :key || type == :keyreq
      param
    }*", "

    puts template %(sig)
    nil
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
debugging-2.1.0 lib/debugging/howtocall.rb
debugging-2.0.0 lib/debugging/howtocall.rb
debugging-1.1.2 lib/debugging/howtocall.rb
debugging-1.1.1 lib/debugging/howtocall.rb