Method: FastRI::RiIndex#namespaces_under_matching

Defined in:
lib/fastri/ri_index.rb

#namespaces_under_matching(class_entry_or_name, regexp, recursive, scope = nil) ⇒ Object

Returns array of ClassEntry objects under class_entry_or_name (either String or ClassEntry) in the hierarchy whose full_name matches the given regexp.



414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/fastri/ri_index.rb', line 414

def namespaces_under_matching(class_entry_or_name, regexp, recursive, scope = nil)
  case class_entry_or_name
  when ClassEntry
    class_entry = class_entry_or_name
  when ""
    class_entry = top_level_namespace(scope)[0]
  else
    class_entry = get_entry(@namespace_array, class_entry_or_name, ClassEntry, scope)
  end
  return [] unless class_entry
  ret = []
  re1, re2 = matching_regexps_namespace(class_entry.full_name)
  (class_entry.index+1...@namespace_array.size).each do |i|
    entry = @namespace_array[i]
    break unless re1 =~ entry
    next if !recursive && re2 !~ entry 
    full_name = entry[/\S+/]
    next unless regexp =~ full_name
    if scope
      sources = namespace_sources(i)
      if sources.include?(sindex = scope_to_sindex(scope))
        ret << ClassEntry.new(self, full_name, i, sindex)
      end
    else
      ret << ClassEntry.new(self, full_name, i, nil)
    end
  end
  ret
end