Class: RiDatabase
Overview
Handle RDoc(ri) database for tools/bc-rdoc.rb and ‘bitclust methods –diff`.
Instance Attribute Summary collapse
-
#class ⇒ Object
readonly
Returns the value of attribute class.
-
#instance_methods ⇒ Object
readonly
Returns the value of attribute instance_methods.
-
#singleton_methods ⇒ Object
readonly
Returns the value of attribute singleton_methods.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #current_class=(name) ⇒ Object
- #get_method(m) ⇒ Object
-
#initialize(ripath, version) ⇒ RiDatabase
constructor
A new instance of RiDatabase.
- #lookup_class(name) ⇒ Object
Constructor Details
#initialize(ripath, version) ⇒ RiDatabase
Returns a new instance of RiDatabase.
20 21 22 23 24 |
# File 'lib/bitclust/ridatabase.rb', line 20 def initialize(ripath, version) @ripath = ripath @reader = RI::RiReader.new(RI::RiCache.new(@ripath)) @version = version end |
Instance Attribute Details
#class ⇒ Object (readonly)
Returns the value of attribute class.
42 43 44 |
# File 'lib/bitclust/ridatabase.rb', line 42 def class @class end |
#instance_methods ⇒ Object (readonly)
Returns the value of attribute instance_methods.
44 45 46 |
# File 'lib/bitclust/ridatabase.rb', line 44 def instance_methods @instance_methods end |
#singleton_methods ⇒ Object (readonly)
Returns the value of attribute singleton_methods.
43 44 45 |
# File 'lib/bitclust/ridatabase.rb', line 43 def singleton_methods @singleton_methods end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
26 27 28 |
# File 'lib/bitclust/ridatabase.rb', line 26 def version @version end |
Class Method Details
.open(dir, version) ⇒ Object
16 17 18 |
# File 'lib/bitclust/ridatabase.rb', line 16 def RiDatabase.open(dir, version) new(RI::Paths.path(false, false, false, false, dir), version) end |
.open_system_db ⇒ Object
12 13 14 |
# File 'lib/bitclust/ridatabase.rb', line 12 def RiDatabase.open_system_db new(RI::Paths.path(true, false, false, false), RUBY_VERSION) end |
Instance Method Details
#current_class=(name) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/bitclust/ridatabase.rb', line 32 def current_class=(name) @klass = lookup_class(name) @singleton_methods = wrap_entries(@reader.singleton_methods(@klass)) @instance_methods = wrap_entries(@reader.instance_methods(@klass)) rescue RiClassNotFound @klass = nil @singleton_methods = [] @instance_methods = [] end |
#get_method(m) ⇒ Object
28 29 30 |
# File 'lib/bitclust/ridatabase.rb', line 28 def get_method(m) @reader.get_method(m) end |
#lookup_class(name) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/bitclust/ridatabase.rb', line 46 def lookup_class(name) ns = @reader.top_level_namespace.first name.split('::').each do |const| ns = ns.contained_class_named(const) or raise RiClassNotFound, "no such class in RDoc database: #{name}" end ns end |