Sha256: a89d9201089f4e2578391ad9a99670e3665fb03c4314f1db92d73f5dea0e5fd7

Contents?: true

Size: 599 Bytes

Versions: 14

Compression:

Stored size: 599 Bytes

Contents

module Reek
  module Core

    #
    # Manages and counts the references out of a method to other objects.
    #
    class ObjectRefs  # :nodoc:
      def initialize
        @refs = Hash.new(0)
      end

      def record_reference_to(exp)
        @refs[exp] += 1
      end

      def references_to(exp)
        @refs[exp]
      end

      def max_refs
        @refs.values.max or 0
      end

      def max_keys
        max = max_refs
        @refs.reject {|key,val| val != max}
      end

      def self_is_max?
        max_keys.length == 0 || @refs[:self] == max_refs
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
reek-1.3.8 lib/reek/core/object_refs.rb
reek-1.3.7 lib/reek/core/object_refs.rb
reek-1.3.6 lib/reek/core/object_refs.rb
reek-1.3.5 lib/reek/core/object_refs.rb
reek-1.3.4 lib/reek/core/object_refs.rb
reek-1.3.3 lib/reek/core/object_refs.rb
reek-1.3.2 lib/reek/core/object_refs.rb
reek-1.3.1 lib/reek/core/object_refs.rb
reek-1.3 lib/reek/core/object_refs.rb
reek-1.2.13 lib/reek/core/object_refs.rb
reek-1.2.12 lib/reek/core/object_refs.rb
reek-1.2.11 lib/reek/core/object_refs.rb
reek-1.2.10 lib/reek/core/object_refs.rb
reek-1.2.9 lib/reek/core/object_refs.rb