Class: Synvert::Core::Rewriter::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/synvert/core/rewriter/condition.rb

Overview

Condition checks if rules matches.

Instance Method Summary collapse

Constructor Details

#initialize(instance, rules, &block) ⇒ Synvert::Core::Rewriter::Condition

Initialize a condition.

Parameters:



12
13
14
15
16
# File 'lib/synvert/core/rewriter/condition.rb', line 12

def initialize(instance, rules, &block)
  @instance = instance
  @rules = rules
  @block = block
end

Instance Method Details

#processObject

If condition matches, run the block code.



19
20
21
# File 'lib/synvert/core/rewriter/condition.rb', line 19

def process
  @instance.instance_eval &@block if match?
end