Sha256: f818a5802c1f0074bb0cadb1ed2e6f88906ad03d336ae20d52f1b5a115ec4e8b
Contents?: true
Size: 902 Bytes
Versions: 3
Compression:
Stored size: 902 Bytes
Contents
# frozen_string_literal: true module Synvert::Core::NodeQuery::Compiler # Regexp represents a ruby regexp value. class Regexp include Comparable # Initialize a Regexp. # @param value [Regexp] the regexp value def initialize(value:) @value = value end # Check if the regexp value matches the node value. # @param node [Parser::AST::Node] the node # @param operator [Symbol] the operator # @return [Boolean] true if the regexp value matches the node value, otherwise, false. def match?(node, operator = '=~') match = if node.is_a?(::Parser::AST::Node) @value.match(node.to_source) else @value.match(node.to_s) end operator == '=~' ? match : !match end # Get valid operators. def valid_operators REGEXP_VALID_OPERATORS end def to_s @value.to_s end end end
Version data entries
3 entries across 3 versions & 1 rubygems