Class RDoc::RI::NameDescriptor
In: ri/util.rb
Parent: Object

Break argument into its constituent class or module names, an optional method type, and a method name

Methods

Public Class methods

arg may be

  1. A class or module name (optionally qualified with other class or module names (Kernel, File::Stat etc)
  2. A method name
  3. A method name qualified by a optionally fully qualified class or module name

We‘re fairly casual about delimiters: folks can say Kernel::puts, Kernel.puts, or Kernel\puts for example. There‘s one exception: if you say IO::read, we look for a class method, but if you say IO.read, we look for an instance method

[Source]

    # File ri/util.rb, line 33
33:   def initialize(arg)
34:     @class_names = []
35:     separator = nil
36: 
37:     tokens = arg.split(/(\.|::|#)/)
38: 
39:     # Skip leading '::', '#' or '.', but remember it might
40:     # be a method name qualifier
41:     separator = tokens.shift if tokens[0] =~ /^(\.|::|#)/
42: 
43:     # Skip leading '::', but remember we potentially have an inst
44: 
45:     # leading stuff must be class names
46: 
47:     while tokens[0] =~ /^[A-Z]/
48:       @class_names << tokens.shift
49:       unless tokens.empty?
50:         separator = tokens.shift
51:         break unless separator == "::"
52:       end
53:     end
54: 
55:     # Now must have a single token, the method name, or an empty array
56:     unless tokens.empty?
57:       @method_name = tokens.shift
58:       # We may now have a trailing !, ?, or = to roll into
59:       # the method name
60:       if !tokens.empty? && tokens[0] =~ /^[!?=]$/
61:         @method_name << tokens.shift
62:       end
63: 
64:       if @method_name =~ /::|\.|#/ or !tokens.empty?
65:         raise RiError.new("Bad argument: #{arg}") 
66:       end
67:       if separator && separator != '.'
68:         @is_class_method = separator == "::"
69:       end
70:     end
71:   end

Public Instance methods

Return the full class name (with ’::’ between the components) or "" if there‘s no class name

[Source]

    # File ri/util.rb, line 76
76:   def full_class_name
77:     @class_names.join("::")
78:   end

[Validate]