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



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

def initialize(context)
  super()
  @context = context
  @strictnesses = {} #: Hash[Node, String?]
end

Instance Attribute Details

#strictnessesObject (readonly)

: Hash[Node, String?]



137
138
139
# File 'lib/spoom/file_tree.rb', line 137

def strictnesses
  @strictnesses
end

Instance Method Details

#visit_node(node) ⇒ Object

: (FileTree::Node node) -> void



148
149
150
151
152
153
# File 'lib/spoom/file_tree.rb', line 148

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

  super
end