Sha256: 6abfe512267b738a2aa4f5743c05de3180372390169971170dc935410dc11a22

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

module Reconn
module Analyzer
  # Represents a class in the project
  class Class
    attr_reader :name, :methods, :filepaths
    attr_accessor :lines, :complexity, :dependencies, :external_deps

    include Comparable

    def ==(other)
      name == other.name
    end

    def initialize(name, filepaths = [])
      @name = name
      @filepaths = filepaths
      @dependencies = []
      @methods = []
      @lines = 0
      @complexity = 0
    end

    def add_dependency(class_name)
      @dependencies << class_name.to_s
    end

    def add_method(method_name)
      @methods << method_name
    end

    def methods_number
      methods.size
    end

    def +(other)
      other.methods.each do |method|
        if !@methods.index(method)
          @methods << method
        end
      end
      @dependencies += other.dependencies
      @filepaths += other.filepaths
      self
    end

    def to_s
      name.to_s
    end

  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
reconn-1.0.0 lib/reconn/analyzer/project_elements/class.rb