Sha256: bbbc2cecb001ec9dbf2f0fbf8a1bf8c198787e04518de2750168be3fbe64ca52

Contents?: true

Size: 418 Bytes

Versions: 3

Compression:

Stored size: 418 Bytes

Contents

# frozen_string_literal: true

module Synvert::Core
  # IfExistCondition checks if node has only one child node and the child node matches rules.
  class Rewriter::IfOnlyExistCondition < Rewriter::Condition
    # check if only have one child node and the child node matches rules.
    def match?
      @instance.current_node.body.size == 1 &&
        @instance.current_node.body.first.match?(@rules)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
synvert-core-0.17.0 lib/synvert/core/rewriter/condition/if_only_exist_condition.rb
synvert-core-0.16.1 lib/synvert/core/rewriter/condition/if_only_exist_condition.rb
synvert-core-0.16.0 lib/synvert/core/rewriter/condition/if_only_exist_condition.rb