Class: IRB::ExtendCommand::ShowSource

Inherits:
Nop show all
Defined in:
lib/irb/cmd/show_source.rb

Instance Attribute Summary

Attributes inherited from Nop

#irb_context

Instance Method Summary collapse

Methods inherited from Nop

execute, #initialize, #irb

Constructor Details

This class inherits a constructor from IRB::ExtendCommand::Nop

Instance Method Details

#execute(str = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/irb/cmd/show_source.rb', line 11

def execute(str = nil)
  unless str.is_a?(String)
    puts "Error: Expected a string but got #{str.inspect}"
    return
  end
  source = find_source(str)
  if source && File.exist?(source.file)
    show_source(source)
  else
    puts "Error: Couldn't locate a definition for #{str}"
  end
  nil
end