class RuboCop::AST::RegexpNode

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.

Constants

OPTIONS

Public Instance Methods

content() click to toggle source

@return [String] a string of regexp content

# File lib/rubocop/ast/node/regexp_node.rb, line 28
def content
  str = children.first
  str.str_content || ''
end
regopt() click to toggle source

@return [RuboCop::AST::Node] a regopt node

# File lib/rubocop/ast/node/regexp_node.rb, line 22
def regopt
  first, second = *self
  first.regopt_type? ? first : second
end
to_regexp() click to toggle source

@return [Regexp] a regexp of this node

# File lib/rubocop/ast/node/regexp_node.rb, line 16
def to_regexp
  option = regopt.children.map { |opt| OPTIONS[opt] }.inject(:|)
  Regexp.new(content, option)
end