Class: CheapCoder::NodeDetector::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cheap_coder/node_detector/base.rb

Direct Known Subclasses

Assignment, Branch, Condition

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



8
9
10
# File 'lib/cheap_coder/node_detector/base.rb', line 8

def initialize
  @score = 0
end

Instance Attribute Details

#scoreObject (readonly)

Returns the value of attribute score.



6
7
8
# File 'lib/cheap_coder/node_detector/base.rb', line 6

def score
  @score
end

Instance Method Details

#check(node) ⇒ Object



12
13
14
15
16
17
# File 'lib/cheap_coder/node_detector/base.rb', line 12

def check(node)
  return unless detected?(node)

  print_debug(node)
  @score += 1
end


19
20
21
22
23
24
# File 'lib/cheap_coder/node_detector/base.rb', line 19

def print_debug(node)
  return unless ENV['CHEAP_CODER_LOGGER_VERBOSE'] == 'true'

  class_type = self.class.name.split('::').last
  puts "[#{class_type}] #{Unparser.unparse(node)}"
end