| Class | IHelp::IHelpDriver |
| In: |
lib/ihelp.rb
|
| Parent: | RiDriver |
Version of RiDriver that takes its options as parameter to initialize.
Create new IHelpDriver, with the given args passed to @options, which is a RI::Options.instance
# File lib/ihelp.rb, line 353
353: def initialize(args = [])
354: @options = RI::Options.instance
355: @options.parse(args)
356:
357: paths = @options.paths || RI::Paths::PATH
358: if paths.empty?
359: report_missing_documentation(paths)
360: end
361: @ri_reader = RI::RiReader.new(RI::RiCache.new(paths))
362: @display = @options.displayer
363: end
Display the info based on if it’s for a class or a method. Using ri’s pager.
# File lib/ihelp.rb, line 388
388: def display_info(info)
389: case [info.class] # only info.class doesn't work
390: when [RI::ClassDescription]
391: @display.display_class_info(info, @ri_reader)
392: when [RI::MethodDescription]
393: @display.display_method_info(info)
394: end
395: end
Get info for the class in the given namespaces.
# File lib/ihelp.rb, line 399
399: def get_class_info_str(namespaces)
400: return nil if namespaces.empty?
401: klass = nil
402: namespaces.find{|ns|
403: begin
404: klass = @ri_reader.get_class(ns)
405: rescue TypeError
406: nil
407: end
408: }
409: klass
410: end
Get info string from ri database for klass_name [method_name]
# File lib/ihelp.rb, line 367
367: def get_info_str(klass_name, method_name = nil, instance = false)
368: is_class_method = (not instance)
369: top_level_namespace = @ri_reader.top_level_namespace
370: namespaces = klass_name.split(/::/).inject(top_level_namespace){
371: |ns, current_name|
372: @ri_reader.lookup_namespace_in(current_name, ns)
373: }
374: return nil if namespaces.empty?
375: if method_name.nil?
376: get_class_info_str(namespaces)
377: else
378: methods = @ri_reader.find_methods(
379: method_name, is_class_method, namespaces)
380: return nil if methods.empty?
381: get_method_info_str(method_name, methods)
382: end
383: end
Get info for the method in the given methods.
# File lib/ihelp.rb, line 414
414: def get_method_info_str(requested_method_name, methods)
415: if methods.size == 1
416: @ri_reader.get_method(methods.first)
417: else
418: entries = methods.find_all {|m| m.name == requested_method_name}
419: return nil if entries.empty?
420: method = nil
421: entries.find{|entry| method = @ri_reader.get_method(entry)}
422: method
423: end
424: end