Class: FastRI::RiIndex::MethodEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/fastri/ri_index.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ri_index, fullname, index, source_index) ⇒ MethodEntry

Returns a new instance of MethodEntry.



74
75
76
77
78
79
80
81
82
83
# File 'lib/fastri/ri_index.rb', line 74

def initialize(ri_index, fullname, index, source_index)
  # index is the index in ri_index' array
  # source_index either nil (all scopes) or the integer referencing the
  # path (-> we'll do @ri_index.paths[@source_index])
  @ri_index = ri_index
  @full_name = fullname
  @name = fullname[/[.#](.*)$/, 1]
  @index = index
  @source_index = source_index
end

Instance Attribute Details

#full_nameObject (readonly)

Returns the value of attribute full_name.



72
73
74
# File 'lib/fastri/ri_index.rb', line 72

def full_name
  @full_name
end

#indexObject (readonly)

Returns the value of attribute index.



72
73
74
# File 'lib/fastri/ri_index.rb', line 72

def index
  @index
end

#nameObject (readonly)

Returns the value of attribute name.



72
73
74
# File 'lib/fastri/ri_index.rb', line 72

def name
  @name
end

#source_indexObject (readonly)

Returns the value of attribute source_index.



72
73
74
# File 'lib/fastri/ri_index.rb', line 72

def source_index
  @source_index
end

Instance Method Details

#instance_method?Boolean

Returns:

  • (Boolean)


112
113
114
# File 'lib/fastri/ri_index.rb', line 112

def instance_method?
  !singleton_method?
end

#path_nameObject

Returns the “fully resolved” file name of the yaml containing our description.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/fastri/ri_index.rb', line 87

def path_name
  prefix = @full_name.split(/::|[#.]/)[0..-2]
  case @source_index
  when nil
    ## we'd like to do
    #@ri_index.source_paths_for(self).map do |path|
    #  File.join(File.join(path, *prefix), RI::RiWriter.internal_to_external(@name))
    #end
    # but RI doesn't support merging at the method-level, so
    path = @ri_index.source_paths_for(self).first
    File.join(File.join(path, *prefix), 
              RI::RiWriter.internal_to_external(@name) + 
              (singleton_method? ? "-c" : "-i" ) + ".yaml")
  else
    path = @ri_index.paths[@source_index]
    File.join(File.join(path, *prefix), 
              RI::RiWriter.internal_to_external(@name) +
              (singleton_method? ? "-c" : "-i" ) + ".yaml")
  end
end

#singleton_method?Boolean

Returns:

  • (Boolean)


108
109
110
# File 'lib/fastri/ri_index.rb', line 108

def singleton_method?
  /\.[^:]+$/ =~ @full_name
end

#typeObject

Returns the type of this entry (:method).



117
118
119
# File 'lib/fastri/ri_index.rb', line 117

def type
  :method
end