Sha256: a686ebaf9b20b3131461c74bcb9406eef69fe622345441c8af48d5a4eeba1eb9

Contents?: true

Size: 938 Bytes

Versions: 6880

Compression:

Stored size: 938 Bytes

Contents

# frozen_string_literal: true

module RuboCop
  module AST
    # A node extension for `regexp` nodes. This will be used in place of a plain
    # node when the builder constructs the AST, making its methods available
    # to all `regexp` nodes within RuboCop.
    class RegexpNode < Node
      OPTIONS = {
        x: Regexp::EXTENDED,
        i: Regexp::IGNORECASE,
        m: Regexp::MULTILINE,
        n: Regexp::NOENCODING
      }.freeze

      # @return [Regexp] a regexp of this node
      def to_regexp
        option = regopt.children.map { |opt| OPTIONS[opt] }.inject(:|)
        Regexp.new(content, option)
      end

      # @return [RuboCop::AST::Node] a regopt node
      def regopt
        first, second = *self
        first.regopt_type? ? first : second
      end

      # @return [String] a string of regexp content
      def content
        str = children.first
        str.str_content || ''
      end
    end
  end
end

Version data entries

6,880 entries across 6,855 versions & 28 rubygems

Version Path
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.75.1/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.9.1 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/ast/node/regexp_node.rb
rubocop-0.75.1 lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.75.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.9.0 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/ast/node/regexp_node.rb
rubocop-0.75.0 lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.3 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.2 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.1 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/rubocop-0.74.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.8.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb
rubocop-0.74.0 lib/rubocop/ast/node/regexp_node.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/rubocop-0.66.0/lib/rubocop/ast/node/regexp_node.rb
rubocop-0.73.0 lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.7.1 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb
zuora_connect_ui-0.7.0 vendor/ruby/2.6.0/gems/rubocop-0.72.0/lib/rubocop/ast/node/regexp_node.rb