Class: Simplabs::Excellent::Parsing::SingletonMethodContext

Inherits:
MethodContext show all
Includes:
AbcMeasure, CyclomaticComplexityMeasure
Defined in:
lib/simplabs/excellent/parsing/singleton_method_context.rb

Overview

:nodoc:

Constant Summary

Constants included from AbcMeasure

AbcMeasure::CONDITIONS

Constants included from CyclomaticComplexityMeasure

CyclomaticComplexityMeasure::COMPLEXITY_NODE_TYPES

Constants included from FlogMeasure

FlogMeasure::BRANCHES, FlogMeasure::SCORES

Instance Attribute Summary collapse

Attributes inherited from MethodContext

#line_count

Attributes inherited from SexpContext

#file, #line, #name, #parent

Instance Method Summary collapse

Methods included from AbcMeasure

#abc_score, #process_call, #process_lasgn, #process_vcall

Methods included from CyclomaticComplexityMeasure

#cc_score, #process_and, #process_case, #process_for, #process_if, #process_or, #process_rescue, #process_until, #process_when, #process_while

Methods inherited from MethodContext

#has_parameter?

Methods included from FlogMeasure

#flog_score, #process_alias, #process_and, #process_attrasgn, #process_attrset, #process_block_pass, #process_call, #process_case, #process_dasgn_curr, #process_else, #process_iasgn, #process_if, #process_iter, #process_lasgn, #process_lit, #process_masgn, #process_or, #process_rescue, #process_sclass, #process_super, #process_until, #process_when, #process_while, #process_yield

Methods inherited from SexpContext

#method_missing

Constructor Details

#initialize(exp, parent) ⇒ SingletonMethodContext

Returns a new instance of SingletonMethodContext.



18
19
20
21
22
23
# File 'lib/simplabs/excellent/parsing/singleton_method_context.rb', line 18

def initialize(exp, parent)
  super
  @name = exp[2].to_s
  @full_name = get_full_name
  @calls = Hash.new(0)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Simplabs::Excellent::Parsing::SexpContext

Instance Attribute Details

#callsObject (readonly)

Returns the value of attribute calls.



16
17
18
# File 'lib/simplabs/excellent/parsing/singleton_method_context.rb', line 16

def calls
  @calls
end

#parametersObject (readonly)

Returns the value of attribute parameters.



15
16
17
# File 'lib/simplabs/excellent/parsing/singleton_method_context.rb', line 15

def parameters
  @parameters
end

Instance Method Details

#full_nameObject



25
26
27
28
29
30
# File 'lib/simplabs/excellent/parsing/singleton_method_context.rb', line 25

def full_name
  return @full_name if @full_name
  parent = @parent.is_a?(BlockContext) ? @parent.parent : @parent
  return @name if parent.blank?
  "#{parent.full_name}.#{@name}"
end

#record_call_to(exp) ⇒ Object



32
33
34
# File 'lib/simplabs/excellent/parsing/singleton_method_context.rb', line 32

def record_call_to(exp)
  @calls[exp] += 1
end