Class: Synvert::Core::Rewriter::IfOnlyExistCondition

Inherits:
Condition
  • Object
show all
Defined in:
lib/synvert/core/rewriter/condition/if_only_exist_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::Core::Rewriter::Condition

Instance Method Details

#match?Boolean

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

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/synvert/core/rewriter/condition/if_only_exist_condition.rb', line 7

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