Class: Foundries::Similarity::Recorder
- Inherits:
-
Object
- Object
- Foundries::Similarity::Recorder
- Defined in:
- lib/foundries/similarity/recorder.rb
Instance Method Summary collapse
-
#initialize ⇒ Recorder
constructor
A new instance of Recorder.
- #normalized_tree ⇒ Object
- #record(method_name, has_block:) ⇒ Object
Constructor Details
#initialize ⇒ Recorder
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_tree ⇒ Object
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 |