Class: Spoom::FileTree::CollectStrictnesses

Inherits:
Visitor
  • Object
show all
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

: (Context context) -> void



143
144
145
146
147
# File 'lib/spoom/file_tree.rb', line 143

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

Instance Attribute Details

#strictnessesObject (readonly)

: Hash[Node, String?]



140
141
142
# File 'lib/spoom/file_tree.rb', line 140

def strictnesses
  @strictnesses
end

Instance Method Details

#visit_node(node) ⇒ Object

: (FileTree::Node node) -> void



151
152
153
154
155
156
# File 'lib/spoom/file_tree.rb', line 151

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

  super
end