Sha256: 45317fcf72c7e72b6c7b70cae2b450d3fec377b8103e65c833b166d558fd4171

Contents?: true

Size: 1.14 KB

Versions: 8

Compression:

Stored size: 1.14 KB

Contents

require 'simplabs/excellent/parsing/cyclomatic_complexity_measure'
require 'simplabs/excellent/parsing/abc_measure'
require 'simplabs/excellent/parsing/flog_measure'

module Simplabs

  module Excellent

    module Parsing

      class MethodContext < SexpContext #:nodoc:

        include CyclomaticComplexityMeasure
        include AbcMeasure
        include FlogMeasure

        attr_reader :parameters
        attr_reader :calls
        attr_reader :line_count

        def initialize(exp, parent)
          super
          @parameters = []
          @name       = exp[1].to_s
          @parent.methods << self if @parent && (@parent.is_a?(ClassContext) || @parent.is_a?(ModuleContext))
          @calls      = Hash.new(0)
          @line_count = count_lines
        end

        def has_parameter?(parameter)
          @parameters.include?(parameter)
        end

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

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

      end

    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
excellent-2.1.1 lib/simplabs/excellent/parsing/method_context.rb
excellent-2.1.0 lib/simplabs/excellent/parsing/method_context.rb
excellent-2.0.1 lib/simplabs/excellent/parsing/method_context.rb
excellent-2.0.0 lib/simplabs/excellent/parsing/method_context.rb
excellent-1.7.2 lib/simplabs/excellent/parsing/method_context.rb
excellent-1.7.1 lib/simplabs/excellent/parsing/method_context.rb
excellent-1.7.0 lib/simplabs/excellent/parsing/method_context.rb
excellent-1.6.0 lib/simplabs/excellent/parsing/method_context.rb