Class: Reek::AST::ObjectRefs Private
- Inherits:
-
Object
- Object
- Reek::AST::ObjectRefs
- 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
-
#initialize ⇒ ObjectRefs
constructor
private
:nodoc:.
- #max_keys ⇒ Object private
- #max_refs ⇒ Object private
- #record_reference_to(exp) ⇒ Object private
- #references_to(exp) ⇒ Object private
- #self_is_max? ⇒ Boolean private
Constructor Details
#initialize ⇒ ObjectRefs
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_keys ⇒ 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.
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_refs ⇒ 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.
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.
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 |