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.63.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.63.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.62.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.62.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.61.2 lib/synvert/core/rewriter/condition.rb
synvert-core-0.61.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.61.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.60.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.59.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.58.3 lib/synvert/core/rewriter/condition.rb
synvert-core-0.58.2 lib/synvert/core/rewriter/condition.rb
synvert-core-0.58.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.57.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.57.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.56.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.56.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.55.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.54.3 lib/synvert/core/rewriter/condition.rb
synvert-core-0.54.2 lib/synvert/core/rewriter/condition.rb
synvert-core-0.54.1 lib/synvert/core/rewriter/condition.rb