Sha256: f47e5c22835e02a6a5f4d4a9e74e47675a25656d5c0f46bae989170cbefc6174

Contents?: true

Size: 916 Bytes

Versions: 1

Compression:

Stored size: 916 Bytes

Contents

require 'debugging'

module Debugging
  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

1 entries across 1 versions & 1 rubygems

Version Path
debugging-1.1.0 lib/debugging/howtocall.rb