Class: IRB::ExtendCommand::ShowSource
- Defined in:
- lib/irb/cmd/show_source.rb
Instance Attribute Summary
Attributes inherited from Nop
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Nop
category, description, execute, #initialize
Constructor Details
This class inherits a constructor from IRB::ExtendCommand::Nop
Class Method Details
.transform_args(args) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/irb/cmd/show_source.rb', line 15 def transform_args(args) # Return a string literal as is for backward compatibility if args.empty? || string_literal?(args) args else # Otherwise, consider the input as a String for convenience args.strip.dump end end |
Instance Method Details
#execute(str = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/irb/cmd/show_source.rb', line 25 def execute(str = nil) unless str.is_a?(String) puts "Error: Expected a string but got #{str.inspect}" return end str, esses = str.split(" -") super_level = esses ? esses.count("s") : 0 source = SourceFinder.new(@irb_context).find_source(str, super_level) if source show_source(source) elsif super_level > 0 puts "Error: Couldn't locate a super definition for #{str}" else puts "Error: Couldn't locate a definition for #{str}" end nil end |