Class: Simplabs::Excellent::Parsing::BlockContext

Inherits:
SexpContext
  • Object
show all
Includes:
CyclomaticComplexityMeasure, FlogMeasure
Defined in:
lib/simplabs/excellent/parsing/block_context.rb

Overview

:nodoc:

Constant Summary

Constants included from FlogMeasure

FlogMeasure::BRANCHES, FlogMeasure::SCORES

Constants included from CyclomaticComplexityMeasure

CyclomaticComplexityMeasure::COMPLEXITY_NODE_TYPES

Instance Attribute Summary collapse

Attributes inherited from SexpContext

#file, #line, #name, #parent

Instance Method Summary collapse

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 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 SexpContext

#method_missing

Constructor Details

#initialize(exp, parent) ⇒ BlockContext

Returns a new instance of BlockContext.



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

def initialize(exp, parent)
  super
  @parameters = []
  @name       = 'block'
  @line       = exp.line < exp[1].line ? exp.line : exp[1].line
  @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.



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

def calls
  @calls
end

#parametersObject (readonly)

Returns the value of attribute parameters.



14
15
16
# File 'lib/simplabs/excellent/parsing/block_context.rb', line 14

def parameters
  @parameters
end

Instance Method Details

#full_nameObject



25
26
27
# File 'lib/simplabs/excellent/parsing/block_context.rb', line 25

def full_name
  @name
end

#inside_block?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/simplabs/excellent/parsing/block_context.rb', line 33

def inside_block?
  @parent.is_a?(BlockContext)
end

#record_call_to(exp) ⇒ Object



29
30
31
# File 'lib/simplabs/excellent/parsing/block_context.rb', line 29

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