Class: RBI::Index
- Extended by:
- T::Sig
- Includes:
- T::Enumerable
- Defined in:
- lib/rbi/index.rb
Class Method Summary collapse
Instance Method Summary collapse
- #[](id) ⇒ Object
- #index(*nodes) ⇒ Object
-
#initialize ⇒ Index
constructor
A new instance of Index.
- #keys ⇒ Object
- #visit(node) ⇒ Object
Methods inherited from Visitor
Constructor Details
#initialize ⇒ Index
Returns a new instance of Index.
21 22 23 24 |
# File 'lib/rbi/index.rb', line 21 def initialize super @index = T.let({}, T::Hash[String, T::Array[Node]]) end |
Class Method Details
.index(*node) ⇒ Object
13 14 15 16 17 |
# File 'lib/rbi/index.rb', line 13 def index(*node) index = Index.new index.visit_all(node) index end |
Instance Method Details
#[](id) ⇒ Object
32 33 34 |
# File 'lib/rbi/index.rb', line 32 def [](id) @index[id] ||= [] end |
#index(*nodes) ⇒ Object
37 38 39 |
# File 'lib/rbi/index.rb', line 37 def index(*nodes) nodes.each { |node| visit(node) } end |
#keys ⇒ Object
27 28 29 |
# File 'lib/rbi/index.rb', line 27 def keys @index.keys end |
#visit(node) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rbi/index.rb', line 42 def visit(node) return unless node case node when Scope index_node(node) visit_all(node.nodes) when Tree visit_all(node.nodes) when Indexable index_node(node) end end |