Class: IRB::Command::Code

Inherits:
Base
  • Object
show all
Defined in:
lib/irbtools/commands/code.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.transform_args(args) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/irbtools/commands/code.rb', line 10

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

Instance Method Details

#execute(*args) ⇒ Object



27
28
29
30
31
# File 'lib/irbtools/commands/code.rb', line 27

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