Class: Pry::CInternals::ETagParser

Inherits:
Object
  • Object
show all
Defined in:
lib/pry-doc/pry_ext/show_source_with_c_internals/c_file.rb,
lib/pry-doc/pry_ext/show_source_with_c_internals/etag_parser.rb

Defined Under Namespace

Classes: CFile, SourceLocation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tags_path, ruby_source_folder) ⇒ ETagParser

Returns a new instance of ETagParser.



14
15
16
17
# File 'lib/pry-doc/pry_ext/show_source_with_c_internals/etag_parser.rb', line 14

def initialize(tags_path, ruby_source_folder)
  @tags_path = tags_path
  @ruby_source_folder = ruby_source_folder
end

Instance Attribute Details

#ruby_source_folderObject (readonly)

Returns the value of attribute ruby_source_folder.



8
9
10
# File 'lib/pry-doc/pry_ext/show_source_with_c_internals/etag_parser.rb', line 8

def ruby_source_folder
  @ruby_source_folder
end

#tags_pathObject (readonly)

Returns the value of attribute tags_path.



7
8
9
# File 'lib/pry-doc/pry_ext/show_source_with_c_internals/etag_parser.rb', line 7

def tags_path
  @tags_path
end

Class Method Details

.symbol_map_for(tags_path, ruby_source_folder) ⇒ Object



10
11
12
# File 'lib/pry-doc/pry_ext/show_source_with_c_internals/etag_parser.rb', line 10

def self.symbol_map_for(tags_path, ruby_source_folder)
  new(tags_path, ruby_source_folder).symbol_map
end

Instance Method Details

#symbol_mapObject



19
20
21
22
23
24
25
26
27
28
# File 'lib/pry-doc/pry_ext/show_source_with_c_internals/etag_parser.rb', line 19

def symbol_map
  parse_tagfile.each_with_object({}) do |c_file, hash|
    # Append all the SourceLocations for a symbol to the same array
    # e.g
    # { "foo" => [SourceLocation_1] }
    # { "foo" => [SourceLocation_2] }
    # => { "foo" => [SourceLocation_1, SourceLocation_2] }
    hash.merge!(c_file.symbol_map) { |key, old_val, new_val| old_val + new_val }
  end
end