# File lib/pry/method.rb, line 248 def source @source ||= case source_type when :c info = pry_doc_info if info and info.source code = strip_comments_from_c_code(info.source) end when :ruby # clone of MethodSource.source_helper that knows to use our # hacked version of source_location for rbx core methods, and # our input buffer for methods defined in (pry) file, line = *source_location raise SourceNotFoundError, "Could not locate source for #{name_with_owner}!" unless file begin code = Pry::Code.from_file(file).expression_at(line) rescue SyntaxError => e raise MethodSource::SourceNotFoundError.new(e.message) end strip_leading_whitespace(code) end end