1## 2# A normal class, neither singleton nor anonymous 3 4class RDoc::NormalClass < RDoc::ClassModule 5 6 ## 7 # The ancestors of this class including modules. Unlike Module#ancestors, 8 # this class is not included in the result. The result will contain both 9 # RDoc::ClassModules and Strings. 10 11 def ancestors 12 if String === superclass then 13 super << superclass 14 elsif superclass then 15 ancestors = super 16 ancestors << superclass 17 ancestors.concat superclass.ancestors 18 else 19 super 20 end 21 end 22 23 ## 24 # The definition of this class, <tt>class MyClassName</tt> 25 26 def definition 27 "class #{full_name}" 28 end 29 30 def direct_ancestors 31 superclass ? super + [superclass] : super 32 end 33 34 def inspect # :nodoc: 35 superclass = @superclass ? " < #{@superclass}" : nil 36 "<%s:0x%x class %s%s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [ 37 self.class, object_id, 38 full_name, superclass, @includes, @extends, @attributes, @method_list, @aliases 39 ] 40 end 41 42 def to_s # :nodoc: 43 display = "#{self.class.name} #{self.full_name}" 44 if superclass 45 display << ' < ' << (superclass.is_a?(String) ? superclass : superclass.full_name) 46 end 47 display << ' -> ' << is_alias_for.to_s if is_alias_for 48 display 49 end 50 51 def pretty_print q # :nodoc: 52 superclass = @superclass ? " < #{@superclass}" : nil 53 54 q.group 2, "[class #{full_name}#{superclass} ", "]" do 55 q.breakable 56 q.text "includes:" 57 q.breakable 58 q.seplist @includes do |inc| q.pp inc end 59 60 q.breakable 61 q.text "constants:" 62 q.breakable 63 q.seplist @constants do |const| q.pp const end 64 65 q.breakable 66 q.text "attributes:" 67 q.breakable 68 q.seplist @attributes do |attr| q.pp attr end 69 70 q.breakable 71 q.text "methods:" 72 q.breakable 73 q.seplist @method_list do |meth| q.pp meth end 74 75 q.breakable 76 q.text "aliases:" 77 q.breakable 78 q.seplist @aliases do |aliaz| q.pp aliaz end 79 80 q.breakable 81 q.text "comment:" 82 q.breakable 83 q.pp comment 84 end 85 end 86 87end 88 89