Sha256: db7194054dce6b59519e9cc0d71c291afa02dc17f7b31ab0846d7bbbdfee064d

Contents?: true

Size: 791 Bytes

Versions: 5

Compression:

Stored size: 791 Bytes

Contents

require "irb/cmd/nop"

module IRB
  module ExtendCommand
    class Howtocall < Nop
      category "Introspection"
      description "Displays method signatures based on Method#parameters"

      class << self
        def transform_args(args)
          if args.strip =~ /\A(?:([\w:]+)([#.]))?(\w+[?!]?)\z/
            if $1
              if $2 == "#"
                "#{$1}, #{$1}.instance_method(:#{$3})"
              else
                "#{$1}, :#{$3}"
              end
            else
              ":" + $3
            end
          else
            args
          end
        end
      end

      def execute(*args)
        @irb_context.workspace.binding.send(:howtocall, *args)
      rescue NameError
        warn "howtocall: Class or method not found"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
irbtools-4.0.7 lib/irbtools/commands/howtocall.rb
irbtools-4.0.6 lib/irbtools/commands/howtocall.rb
irbtools-4.0.5 lib/irbtools/commands/howtocall.rb
irbtools-4.0.4 lib/irbtools/commands/howtocall.rb
irbtools-4.0.3 lib/irbtools/commands/howtocall.rb