Sha256: 0853437fbeb246e7a9cb30d5954c7c2e25a4ae4c941c0ee52b6850526c6ab486

Contents?: true

Size: 1.13 KB

Versions: 7

Compression:

Stored size: 1.13 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.blank?
          "#{parent.full_name}##{@name}"
        end

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

      end

    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
simplabs-excellent-1.2.1 lib/simplabs/excellent/parsing/method_context.rb
simplabs-excellent-1.2.2 lib/simplabs/excellent/parsing/method_context.rb
simplabs-excellent-1.3.0 lib/simplabs/excellent/parsing/method_context.rb
simplabs-excellent-1.3.1 lib/simplabs/excellent/parsing/method_context.rb
simplabs-excellent-1.4.0 lib/simplabs/excellent/parsing/method_context.rb
simplabs-excellent-1.4.1 lib/simplabs/excellent/parsing/method_context.rb
simplabs-excellent-1.4.2 lib/simplabs/excellent/parsing/method_context.rb