module Utils::IRB::Shell

def ri(*patterns, doc: 'ri')

Parameters:
  • doc (String) -- the documentation command to execute (defaults to 'ri')
  • patterns (Array) -- the patterns to search for in the documentation
def ri(*patterns, doc: 'ri')
  patterns.empty? and
    receiver_unless_main(method(__method__)) do |pattern|
      return ri(pattern, doc: doc)
    end
  patterns.map! { |p|
    case
    when Module === p
      p.name
    when p.respond_to?(:to_str)
      p.to_str
    else
      p.class.name
    end
  }
  system "#{doc} #{patterns.map { |p| "'#{p}'" } * ' ' } | #$pager"
end