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