Class: Synvert::Core::Rewriter::Condition
- Inherits:
-
Object
- Object
- Synvert::Core::Rewriter::Condition
- Defined in:
- lib/synvert/core/rewriter/condition.rb
Overview
Condition checks if nql or rules matches.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(instance, nql_or_rules) { ... } ⇒ Condition
constructor
Initialize a Condition.
-
#process ⇒ Object
If condition matches, run the block code.
Constructor Details
#initialize(instance, nql_or_rules) { ... } ⇒ Condition
Initialize a Condition.
11 12 13 14 15 |
# File 'lib/synvert/core/rewriter/condition.rb', line 11 def initialize(instance, nql_or_rules, &block) @instance = instance @node_query = NodeQuery.new(nql_or_rules, adapter: instance.current_parser) @block = block end |
Instance Method Details
#process ⇒ Object
If condition matches, run the block code.
18 19 20 |
# File 'lib/synvert/core/rewriter/condition.rb', line 18 def process @instance.instance_eval(&@block) if match? end |