Sha256: 2b6aaf57f094cefda8f0a422c6b05979e75ecec15a42f55a24dbecc1e9052850
Contents?: true
Size: 957 Bytes
Versions: 3
Compression:
Stored size: 957 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, o: 0 }.freeze # Note: The 'o' option is ignored. # # @return [Regexp] a regexp of this node def to_regexp option = regopt.children.map { |opt| OPTIONS.fetch(opt) }.inject(:|) Regexp.new(content, option) end # @return [RuboCop::AST::Node] a regopt node def regopt children.last end # @return [String] a string of regexp content def content children.select(&:str_type?).map(&:str_content).join end end end end
Version data entries
3 entries across 3 versions & 2 rubygems