Class: LogStash::Filters::MathCalculationElements::FieldElement
- Inherits:
-
Object
- Object
- LogStash::Filters::MathCalculationElements::FieldElement
- Includes:
- Util::Loggable
- Defined in:
- lib/logstash/filters/math_calculation_elements.rb
Instance Method Summary collapse
- #get(event_register_context) ⇒ Object
-
#initialize(field, position) ⇒ FieldElement
constructor
supports ‘get` and `set`.
- #inspect ⇒ Object
- #key ⇒ Object
- #literal? ⇒ Boolean
- #set(value, event_register_context) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(field, position) ⇒ FieldElement
supports ‘get` and `set`
68 69 70 71 72 |
# 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 |
Instance Method Details
#get(event_register_context) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# 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 ⇒ Object
103 104 105 |
# File 'lib/logstash/filters/math_calculation_elements.rb', line 103 def inspect "\"#{@description}\"" end |
#key ⇒ Object
74 75 76 |
# File 'lib/logstash/filters/math_calculation_elements.rb', line 74 def key @field end |
#literal? ⇒ Boolean
78 79 80 |
# File 'lib/logstash/filters/math_calculation_elements.rb', line 78 def literal? false end |
#set(value, event_register_context) ⇒ Object
82 83 84 |
# 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 ⇒ Object
107 108 109 |
# File 'lib/logstash/filters/math_calculation_elements.rb', line 107 def to_s @description end |