Class: LatentObjectDetector::Detector

Inherits:
Object
  • Object
show all
Defined in:
lib/latent_object_detector.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(klass) ⇒ Detector

Returns a new instance of Detector.



11
12
13
# File 'lib/latent_object_detector.rb', line 11

def initialize(klass)
  self.klass = klass
end

Instance Attribute Details

#klassObject

Returns the value of attribute klass.



5
6
7
# File 'lib/latent_object_detector.rb', line 5

def klass
  @klass
end

Class Method Details

.for(klass) ⇒ Object



7
8
9
# File 'lib/latent_object_detector.rb', line 7

def self.for(klass)
  new(klass)
end

Instance Method Details

#potential_objectsObject



19
20
21
22
# File 'lib/latent_object_detector.rb', line 19

def potential_objects
  common_words = find_common_words_in(hash_of_words_used_in_methods)
  words_used_more_than_twice(common_words)
end

#suspicious_methodsObject



15
16
17
# File 'lib/latent_object_detector.rb', line 15

def suspicious_methods
  methods_owned_by_klass.select{ |m| (words_in_method(m.to_s) & potential_objects).size > 0 }
end