Class: Foundries::Similarity::Recorder

Inherits:
Object
  • Object
show all
Defined in:
lib/foundries/similarity/recorder.rb

Instance Method Summary collapse

Constructor Details

#initializeRecorder

Returns a new instance of Recorder.



8
9
10
11
# File 'lib/foundries/similarity/recorder.rb', line 8

def initialize
  @root = StructureTree.root(children: [])
  @stack = [@root]
end

Instance Method Details

#normalized_treeObject



25
26
27
# File 'lib/foundries/similarity/recorder.rb', line 25

def normalized_tree
  @root.normalize
end

#record(method_name, has_block:) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/foundries/similarity/recorder.rb', line 13

def record(method_name, has_block:)
  node = StructureTree.new(method_name)
  current_parent.children << node
  if has_block
    @stack.push(node)
    yield
    @stack.pop
  elsif block_given?
    yield
  end
end