Sha256: 4618a2f8c80de0e8a2538f23160fdcf17f552acb4a0fb31882e6deee156aed02

Contents?: true

Size: 602 Bytes

Versions: 18

Compression:

Stored size: 602 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 || 0
      end

      def max_keys
        max = max_refs
        @refs.select { |_key, val| val == max }
      end

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

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
reek-2.2.1 lib/reek/core/object_refs.rb
reek-2.2.0 lib/reek/core/object_refs.rb
reek-2.1.0 lib/reek/core/object_refs.rb
reek-2.0.4 lib/reek/core/object_refs.rb
reek-2.0.3 lib/reek/core/object_refs.rb
reek-2.0.2 lib/reek/core/object_refs.rb
reek-2.0.1 lib/reek/core/object_refs.rb
reek-2.0.0 lib/reek/core/object_refs.rb
reek-1.6.6 lib/reek/core/object_refs.rb
reek-1.6.5 lib/reek/core/object_refs.rb
reek-1.6.4 lib/reek/core/object_refs.rb
reek-1.6.3 lib/reek/core/object_refs.rb
reek-1.6.2 lib/reek/core/object_refs.rb
reek-1.6.1 lib/reek/core/object_refs.rb
reek-1.6.0 lib/reek/core/object_refs.rb
reek-1.5.1 lib/reek/core/object_refs.rb
reek-1.5.0 lib/reek/core/object_refs.rb
reek-1.4.0 lib/reek/core/object_refs.rb