Class: Synvert::Rewriter::IfOnlyExistCondition

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

Overview

IfExistCondition checks if node has only one child node and the child node matches rules.

Instance Method Summary collapse

Methods inherited from Condition

#initialize, #process

Constructor Details

This class inherits a constructor from Synvert::Rewriter::Condition

Instance Method Details

#match?Boolean

check if only have one child node and the child node matches rules.

Returns:

  • (Boolean)


51
52
53
54
# File 'lib/synvert/rewriter/condition.rb', line 51

def match?
  @instance.current_node.body.size == 1 &&
    @instance.current_node.body.first.match?(@instance, @rules)
end