| Class | IHelp::IHelpDriver |
| In: |
lib/ihelp.rb
|
| Parent: | RiDriver |
Version of RiDriver that takes its options as parameter to initialize.
| display | [RW] | |
| ri_reader | [RW] |
Create new IHelpDriver, with the given args passed to @options, which is a RI::Options.instance
# File lib/ihelp.rb, line 499
499: def initialize(args = (ENV["RI"] || "").split)
500: @options = RI::Options.instance
501: @options.parse(args)
502:
503: paths = (if RUBY_VERSION > "1.8.4"
504: @options.doc_dir
505: else
506: @options.paths
507: end) || RI::Paths::PATH
508: if paths.empty?
509: report_missing_documentation(paths)
510: end
511: @ri_reader = RI::RiReader.new(RI::RiCache.new(paths))
512: @display = @options.displayer
513: end
Display the info based on if it‘s for a class or a method. Using ri‘s pager.
# File lib/ihelp.rb, line 538
538: def display_info(info)
539: case [info.class] # only info.class doesn't work
540: when [RI::ClassDescription]
541: @display.display_class_info(info, @ri_reader)
542: when [RI::MethodDescription]
543: @display.display_method_info(info)
544: end
545: end
Get info for the class in the given namespaces.
# File lib/ihelp.rb, line 549
549: def get_class_info_str(namespaces, klass_name)
550: return nil if namespaces.empty?
551: klass_name_last = klass_name.split("::").last
552: klass = nil
553: namespaces.find{|ns|
554: begin
555: ns.name == klass_name_last and
556: klass = @ri_reader.get_class(ns)
557: rescue TypeError
558: nil
559: end
560: }
561: klass
562: end
Get info string from ri database for klass_name [method_name]
# File lib/ihelp.rb, line 517
517: def get_info_str(klass_name, method_name = nil, instance = false)
518: is_class_method = (not instance)
519: top_level_namespace = @ri_reader.top_level_namespace
520: namespaces = klass_name.split(/::/).inject(top_level_namespace){
521: |ns, current_name|
522: @ri_reader.lookup_namespace_in(current_name, ns)
523: }
524: return nil if namespaces.empty?
525: if method_name.nil?
526: get_class_info_str(namespaces, klass_name)
527: else
528: methods = @ri_reader.find_methods(
529: method_name, is_class_method, namespaces)
530: return nil if methods.empty?
531: get_method_info_str(method_name, methods)
532: end
533: end
Get info for the method in the given methods.
# File lib/ihelp.rb, line 566
566: def get_method_info_str(requested_method_name, methods)
567: entries = methods.find_all {|m| m.name == requested_method_name}
568: return nil if entries.empty?
569: method = nil
570: entries.find{|entry| method = @ri_reader.get_method(entry)}
571: method
572: end