Class: Reek::SmellDetectors::NilCheck::NodeFinder
- Inherits:
-
Object
- Object
- Reek::SmellDetectors::NilCheck::NodeFinder
- Defined in:
- lib/reek/smell_detectors/nil_check.rb
Overview
A base class that allows to work on all nodes of a certain type.
Instance Attribute Summary collapse
-
#detector ⇒ Object
readonly
private
Returns the value of attribute detector.
-
#nodes ⇒ Object
readonly
private
Returns the value of attribute nodes.
Instance Method Summary collapse
-
#initialize(ctx, type, detector) ⇒ NodeFinder
constructor
A new instance of NodeFinder.
- #smelly_nodes ⇒ Object
Constructor Details
#initialize(ctx, type, detector) ⇒ NodeFinder
Returns a new instance of NodeFinder.
35 36 37 38 |
# File 'lib/reek/smell_detectors/nil_check.rb', line 35 def initialize(ctx, type, detector) @nodes = ctx.local_nodes(type) @detector = detector end |
Instance Attribute Details
#detector ⇒ Object (readonly, private)
Returns the value of attribute detector.
48 49 50 |
# File 'lib/reek/smell_detectors/nil_check.rb', line 48 def detector @detector end |
#nodes ⇒ Object (readonly, private)
Returns the value of attribute nodes.
48 49 50 |
# File 'lib/reek/smell_detectors/nil_check.rb', line 48 def nodes @nodes end |
Instance Method Details
#smelly_nodes ⇒ Object
40 41 42 43 44 |
# File 'lib/reek/smell_detectors/nil_check.rb', line 40 def smelly_nodes nodes.select do |when_node| detector.detect(when_node) end end |