Class: Reek::AST::ObjectRefs Private

Inherits:
Object
  • Object
show all
Defined in:
lib/reek/ast/object_refs.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Manages and counts the references out of a method to other objects.

Instance Method Summary collapse

Constructor Details

#initializeObjectRefs

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

:nodoc:



8
9
10
# File 'lib/reek/ast/object_refs.rb', line 8

def initialize
  @refs = Hash.new(0)
end

Instance Method Details

#max_keysObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



24
25
26
27
# File 'lib/reek/ast/object_refs.rb', line 24

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

#max_refsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



20
21
22
# File 'lib/reek/ast/object_refs.rb', line 20

def max_refs
  @refs.values.max || 0
end

#record_reference_to(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



12
13
14
# File 'lib/reek/ast/object_refs.rb', line 12

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

#references_to(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/reek/ast/object_refs.rb', line 16

def references_to(exp)
  @refs[exp]
end

#self_is_max?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


29
30
31
# File 'lib/reek/ast/object_refs.rb', line 29

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