Class: Spoom::FileTree::CollectScores

Inherits:
CollectStrictnesses show all
Extended by:
T::Sig
Defined in:
lib/spoom/file_tree.rb

Overview

A visitor that collects the typing score of each node in a tree

Instance Attribute Summary collapse

Attributes inherited from CollectStrictnesses

#strictnesses

Instance Method Summary collapse

Methods inherited from Visitor

#visit_nodes, #visit_tree

Constructor Details

#initialize(context) ⇒ CollectScores

Returns a new instance of CollectScores.



174
175
176
177
178
# File 'lib/spoom/file_tree.rb', line 174

def initialize(context)
  super
  @context = context
  @scores = T.let({}, T::Hash[Node, Float])
end

Instance Attribute Details

#scoresObject (readonly)

Returns the value of attribute scores.



171
172
173
# File 'lib/spoom/file_tree.rb', line 171

def scores
  @scores
end

Instance Method Details

#visit_node(node) ⇒ Object



181
182
183
184
185
# File 'lib/spoom/file_tree.rb', line 181

def visit_node(node)
  super

  @scores[node] = node_score(node)
end