Class: LogStash::Config::AST::RegexpExpression

Inherits:
Node
  • Object
show all
Defined in:
lib/logstash/config/config_ast.rb

Constant Summary

Constants included from LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers

LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::AND_METHOD, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::BOOLEAN_DSL_METHOD_SIGNATURE, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::NAND_METHOD, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::OR_METHOD, LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers::XOR_METHOD

Instance Method Summary collapse

Methods inherited from Node

#text_value_for_comments

Methods included from LogStashCompilerLSCLGrammar::LogStash::Compiler::LSCL::AST::Helpers

#base_id, #base_protocol, #base_source_with_metadata, #base_source_with_metadata=, #compose, #compose_for, #jdsl, jdsl, #line_and_column, #source_meta

Instance Method Details

#compileObject



457
458
459
460
461
462
463
464
465
466
467
# File 'lib/logstash/config/config_ast.rb', line 457

def compile
  operator = recursive_select(LogStash::Config::AST::RegExpOperator).first.text_value
  item, regexp = recursive_select(LogStash::Config::AST::RValue)
  # Compile strings to regexp's
  if regexp.is_a?(LogStash::Config::AST::String)
    regexp = "/#{regexp.text_value[1..-2]}/"
  else
    regexp = regexp.compile
  end
  return "(#{item.compile} #{operator} #{regexp})"
end