class LogStash::Filters::MathFunctions::Power

Public Instance Methods

call(op1, op2) click to toggle source
# File lib/logstash/filters/math_functions.rb, line 83
def call(op1, op2)
  op1 ** op2
end
invalid?(op1, op2, event = nil) click to toggle source
# File lib/logstash/filters/math_functions.rb, line 87
def invalid?(op1, op2, event = nil)
  if op1.is_a?(Numeric) && op1 < 0 && !op2.integer?
    warning = "raising a negative number to a fractional exponent results in a complex number that cannot be stored in an event"
    if event
      # called from filter so log
      logger.warn(warning, "operand 1" => op1, "operand 2" => op2, "event" => event.to_hash)
      return true
    else
      # called from register don't log return warning for the error that is raised
      return warning
    end
  end
  nil
end
name() click to toggle source
# File lib/logstash/filters/math_functions.rb, line 79
def name
  "power"
end