Sha256: d39edb2b0192fe004f2a23b18f8f4b25c4841ae35ab71a89cb1a8c41532924a0

Contents?: true

Size: 909 Bytes

Versions: 2

Compression:

Stored size: 909 Bytes

Contents

require_relative 'method_ri'

class Class
  # just runs ri against the class, outputs a big
  def desc_class options = {}
    # want_output = false, verbose = false
    begin
      puts "begin RI"
      RDoc::RI::Driver.run [to_s, '--no-pager']
      puts 'end ri'
    rescue SystemExit
      # not found
    end

    class_methods = methods(false)
    for ancestor in ancestors[1..-1] # skip the first one, which is yourself
      class_methods -= ancestor.methods(false)
    end

    doc = []
    doc << to_s
    doc += ["non inherited methods:", instance_methods(false).sort.join(", ")]
    doc += ['non inherited class methods:', class_methods.sort.join(', ')]
    doc += ["ancestors:", ancestors.join(', ')] if options[:verbose]
    doc += ["Constants (possible sub classes):",  constants.join(', ')] if constants.length > 0 && options[:verbose]
    puts doc
    doc if options[:want_output]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ri_for-0.4.1 lib/ri_for/class_desc.rb
ri_for-0.4.0 lib/ri_for/class_desc.rb