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.54.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.53.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.52.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.52.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.51.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.51.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.50.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.49.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.49.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.48.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.47.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.46.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.45.2 lib/synvert/core/rewriter/condition.rb
synvert-core-0.45.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.45.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.44.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.44.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.42.1 lib/synvert/core/rewriter/condition.rb
synvert-core-0.42.0 lib/synvert/core/rewriter/condition.rb
synvert-core-0.41.2 lib/synvert/core/rewriter/condition.rb