#!/usr/bin/env ruby # # Shows the documentation for a ruby method or class on the command # line. Usage: # # 1% rubydoc # 2% rubydoc # # 1) Prints the entire class's methods # 2) Prints a specific method from the class # require 'open-uri' require 'cgi' class Rubydoc def initialize end def real_main(argv) if argv.empty? print_usage return end cls = argv.shift if argv.empty? process_class cls else method = argv.shift process_method cls,method end end private def process_class(cls) end def process_method(cls,method) url = class_url cls txt = open(url).read link = nil inside_method = false contents = '' txt.each do |line| if link if inside_method if line.match /