aboutsummaryrefslogtreecommitdiffstats
path: root/lib/rdoc/include.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 07:45:16 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-04-01 07:45:16 +0000
commit46580b51477355fece514573c88cb67030f4a502 (patch)
tree779c1a64466643461b3daa4cd9a3548b84f0fd55 /lib/rdoc/include.rb
parent9b40cdfe8c973a061c5683ad78c283b9ddb8b2e9 (diff)
downloadruby-46580b51477355fece514573c88cb67030f4a502.tar.gz
Import RDoc 2.5
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/include.rb')
-rw-r--r--lib/rdoc/include.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/lib/rdoc/include.rb b/lib/rdoc/include.rb
new file mode 100644
index 0000000000..11a9bdc7ef
--- /dev/null
+++ b/lib/rdoc/include.rb
@@ -0,0 +1,61 @@
+require 'rdoc/code_object'
+
+##
+# A Module include in a class with \#include
+
+class RDoc::Include < RDoc::CodeObject
+
+ ##
+ # Name of included module
+
+ attr_accessor :name
+
+ ##
+ # Creates a new Include for +name+ with +comment+
+
+ def initialize(name, comment)
+ super()
+ @name = name
+ self.comment = comment
+ end
+
+ ##
+ # Includes are sorted by name
+
+ def <=> other
+ return unless self.class === other
+
+ name <=> other.name
+ end
+
+ def == other # :nodoc:
+ self.class == other.class and
+ self.name == other.name
+ end
+
+ ##
+ # Full name based on #module
+
+ def full_name
+ m = self.module
+ RDoc::ClassModule === m ? m.full_name : @name
+ end
+
+ def inspect # :nodoc:
+ "#<%s:0x%x %s.include %s>" % [
+ self.class,
+ object_id,
+ parent_name, @name,
+ ]
+ end
+
+ ##
+ # Attempts to locate the included module object. Returns the name if not
+ # known.
+
+ def module
+ RDoc::TopLevel.find_module_named(@name) || @name
+ end
+
+end
+