Class: CheapCoder::NodeDetector::Base
- Inherits:
-
Object
- Object
- CheapCoder::NodeDetector::Base
- Defined in:
- lib/cheap_coder/node_detector/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#score ⇒ Object
readonly
Returns the value of attribute score.
Instance Method Summary collapse
- #check(node) ⇒ Object
-
#initialize ⇒ Base
constructor
A new instance of Base.
- #print_debug(node) ⇒ Object
Constructor Details
#initialize ⇒ Base
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
#score ⇒ Object (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 |
#print_debug(node) ⇒ Object
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 |