Class: KatakataIrb::TypeAnalyzer::DigTarget

Inherits:
Object
  • Object
show all
Defined in:
lib/katakata_irb/type_analyzer.rb

Instance Method Summary collapse

Constructor Details

#initialize(parents, receiver, &block) ⇒ DigTarget

Returns a new instance of DigTarget.



10
11
12
13
14
# File 'lib/katakata_irb/type_analyzer.rb', line 10

def initialize(parents, receiver, &block)
  @dig_ids = parents.to_h { [_1.__id__, true] }
  @target_id = receiver.__id__
  @block = block
end

Instance Method Details

#dig?(node) ⇒ Boolean

Returns:

  • (Boolean)


16
# File 'lib/katakata_irb/type_analyzer.rb', line 16

def dig?(node) = @dig_ids[node.__id__]

#resolve(type, scope) ⇒ Object



18
19
20
# File 'lib/katakata_irb/type_analyzer.rb', line 18

def resolve(type, scope)
  @block.call type, scope
end

#target?(node) ⇒ Boolean

Returns:

  • (Boolean)


17
# File 'lib/katakata_irb/type_analyzer.rb', line 17

def target?(node) = @target_id == node.__id__