Class: Spoom::FileTree::CollectStrictnesses

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

Overview

A visitor that collects the strictness of each node in a tree

Direct Known Subclasses

CollectScores

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Visitor

#visit_nodes, #visit_tree

Constructor Details

#initialize(context) ⇒ CollectStrictnesses

Returns a new instance of CollectStrictnesses.



167
168
169
170
171
# File 'lib/spoom/file_tree.rb', line 167

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

Instance Attribute Details

#strictnessesObject (readonly)

Returns the value of attribute strictnesses.



164
165
166
# File 'lib/spoom/file_tree.rb', line 164

def strictnesses
  @strictnesses
end

Instance Method Details

#visit_node(node) ⇒ Object



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

def visit_node(node)
  path = node.path
  @strictnesses[node] = @context.read_file_strictness(path) if @context.file?(path)

  super
end