class LogStash::Filters::MathCalculationElements::FieldElement
Public Class Methods
new(field, position)
click to toggle source
supports `get` and `set`
# File lib/logstash/filters/math_calculation_elements.rb, line 68 def initialize(field, position) @field = field @position = position @description = (position == 3 ? "result" : "operand #{@position}").prepend("event ").concat(": '#{@field}'") end
Public Instance Methods
get(event_register_context)
click to toggle source
# File lib/logstash/filters/math_calculation_elements.rb, line 86 def get(event_register_context) value = event_register_context.get(self) if value.nil? logger.warn("field not found", "field" => @field, "event" => event_register_context.event.to_hash) return nil end case value when Numeric value when LogStash::Timestamp, Time value.to_f else logger.warn("field value is not numeric or time", "field" => @field, "value" => value, "event" => event_register_context.event.to_hash) nil end end
inspect()
click to toggle source
# File lib/logstash/filters/math_calculation_elements.rb, line 103 def inspect "\"#{@description}\"" end
key()
click to toggle source
# File lib/logstash/filters/math_calculation_elements.rb, line 74 def key @field end
literal?()
click to toggle source
# File lib/logstash/filters/math_calculation_elements.rb, line 78 def literal? false end
set(value, event_register_context)
click to toggle source
# File lib/logstash/filters/math_calculation_elements.rb, line 82 def set(value, event_register_context) event_register_context.set(self, value) end
to_s()
click to toggle source
# File lib/logstash/filters/math_calculation_elements.rb, line 107 def to_s @description end