Class: Analyzer
- Inherits:
-
Object
- Object
- Analyzer
- Defined in:
- lib/analyst/analyzer.rb
Constant Summary collapse
- CONDITIONALS =
[:if, :or_asgn, :and_asgn, :or, :and]
- DEFAULT_CLASS_NAME =
"Unknown"
Instance Attribute Summary collapse
-
#class_name ⇒ Object
Returns the value of attribute class_name.
-
#content ⇒ Object
Returns the value of attribute content.
-
#edges ⇒ Object
Returns the value of attribute edges.
-
#exits ⇒ Object
Returns the value of attribute exits.
-
#nodes ⇒ Object
Returns the value of attribute nodes.
Instance Method Summary collapse
- #complexity ⇒ Object
- #constants ⇒ Object
- #extract_class_name ⇒ Object
- #extract_methods ⇒ Object
-
#initialize(content) ⇒ Analyzer
constructor
A new instance of Analyzer.
- #method_names ⇒ Object
- #methods ⇒ Object
Constructor Details
#initialize(content) ⇒ Analyzer
Returns a new instance of Analyzer.
11 12 13 14 15 16 |
# File 'lib/analyst/analyzer.rb', line 11 def initialize(content) self.content = content self.edges = 0 self.nodes = 1 self.exits = 1 end |
Instance Attribute Details
#class_name ⇒ Object
Returns the value of attribute class_name.
7 8 9 |
# File 'lib/analyst/analyzer.rb', line 7 def class_name @class_name end |
#content ⇒ Object
Returns the value of attribute content.
7 8 9 |
# File 'lib/analyst/analyzer.rb', line 7 def content @content end |
#edges ⇒ Object
Returns the value of attribute edges.
7 8 9 |
# File 'lib/analyst/analyzer.rb', line 7 def edges @edges end |
#exits ⇒ Object
Returns the value of attribute exits.
7 8 9 |
# File 'lib/analyst/analyzer.rb', line 7 def exits @exits end |
#nodes ⇒ Object
Returns the value of attribute nodes.
7 8 9 |
# File 'lib/analyst/analyzer.rb', line 7 def nodes @nodes end |
Instance Method Details
#complexity ⇒ Object
18 19 20 21 |
# File 'lib/analyst/analyzer.rb', line 18 def complexity return unless traverse(parsed) self.edges - self.nodes + exits end |
#constants ⇒ Object
31 32 33 |
# File 'lib/analyst/analyzer.rb', line 31 def constants @constants ||= constants_from(parsed) end |
#extract_class_name ⇒ Object
43 44 45 46 47 |
# File 'lib/analyst/analyzer.rb', line 43 def extract_class_name return self.class_name if self.class_name && ! self.class_name.empty? found = find_class(parsed) self.class_name = ! found.empty? && found || DEFAULT_CLASS_NAME end |
#extract_methods ⇒ Object
39 40 41 |
# File 'lib/analyst/analyzer.rb', line 39 def extract_methods @methods ||= methods_from(parsed) end |
#method_names ⇒ Object
35 36 37 |
# File 'lib/analyst/analyzer.rb', line 35 def method_names @method_names ||= method_names_from(parsed) end |
#methods ⇒ Object
27 28 29 |
# File 'lib/analyst/analyzer.rb', line 27 def methods @methods ||= methods_from(parsed) end |