Class: MOSAIK::Metrics::Complexity::Processor
- Inherits:
-
AST::Processor
- Object
- AST::Processor
- MOSAIK::Metrics::Complexity::Processor
- Defined in:
- lib/mosaik/metrics/complexity/processor.rb
Overview
Abstract Syntax Tree parser for Ruby code
Instance Attribute Summary collapse
-
#complexities ⇒ Object
readonly
Returns the value of attribute complexities.
Instance Method Summary collapse
-
#initialize ⇒ Processor
constructor
A new instance of Processor.
-
#on_def(node) ⇒ Object
Instance methods.
-
#on_defs(node) ⇒ Object
Class methods.
Constructor Details
#initialize ⇒ Processor
Returns a new instance of Processor.
14 15 16 17 18 19 |
# File 'lib/mosaik/metrics/complexity/processor.rb', line 14 def initialize super # Initialize complexities @complexities = {} end |
Instance Attribute Details
#complexities ⇒ Object (readonly)
Returns the value of attribute complexities.
12 13 14 |
# File 'lib/mosaik/metrics/complexity/processor.rb', line 12 def complexities @complexities end |
Instance Method Details
#on_def(node) ⇒ Object
Instance methods
22 23 24 25 26 27 |
# File 'lib/mosaik/metrics/complexity/processor.rb', line 22 def on_def(node) method_name = node.children[0].to_s # Calculate and store complexity for the method complexities[method_name] = complexity_for(node) end |
#on_defs(node) ⇒ Object
Class methods
30 31 32 33 34 35 |
# File 'lib/mosaik/metrics/complexity/processor.rb', line 30 def on_defs(node) method_name = "self.#{node.children[1]}" # Calculate and store complexity for the method complexities[method_name] = complexity_for(node) end |