Sha256: 3f45f054e87e5fc1ea3ccacb82ed0c97debfcbaa73cc899b71c8d74cd16fa18a

Contents?: true

Size: 570 Bytes

Versions: 72

Compression:

Stored size: 570 Bytes

Contents

# frozen_string_literal: true

module Synvert::Core
  # Condition checks if rules matches.
  class Rewriter::Condition
    # Initialize a condition.
    #
    # @param instance [Synvert::Core::Rewriter::Instance]
    # @param rules [Hash]
    # @param block [Block]
    # @return [Synvert::Core::Rewriter::Condition]
    def initialize(instance, rules, &block)
      @instance = instance
      @rules = rules
      @block = block
    end

    # If condition matches, run the block code.
    def process
      @instance.instance_eval(&@block) if match?
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
synvert-core-0.27.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.27.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.26.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.26.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.25.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.25.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.24.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.23.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.22.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.21.2 lib/synvert/core/rewriter/condition.rb
synvert-core-0.21.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.21.0 lib/synvert/core/rewriter/condition.rb