Class: LogStash::Filters::MathCalculationElements::RegisterElement

Inherits:
Object
  • Object
show all
Defined in:
lib/logstash/filters/math_calculation_elements.rb

Instance Method Summary collapse

Constructor Details

#initialize(reference, position, index) ⇒ RegisterElement

supports ‘get` and `set`



31
32
33
34
35
36
# File 'lib/logstash/filters/math_calculation_elements.rb', line 31

def initialize(reference, position, index)
  @reference = reference
  @position = position
  @index = index
  @description = (position == 3 ? "#{@index}" : "operand #{@position}").prepend("register ").concat(": '#{@reference}'")
end

Instance Method Details

#get(event_register_context) ⇒ Object



51
52
53
# File 'lib/logstash/filters/math_calculation_elements.rb', line 51

def get(event_register_context)
  event_register_context.get(self) #log warning if nil
end

#inspectObject



55
56
57
# File 'lib/logstash/filters/math_calculation_elements.rb', line 55

def inspect
  "\"#{@description}\""
end

#keyObject



38
39
40
# File 'lib/logstash/filters/math_calculation_elements.rb', line 38

def key
  @index
end

#literal?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/logstash/filters/math_calculation_elements.rb', line 42

def literal?
  false
end

#set(value, event_register_context) ⇒ Object



46
47
48
49
# File 'lib/logstash/filters/math_calculation_elements.rb', line 46

def set(value, event_register_context)
  # raise usage error if called when position != 3 ??
  event_register_context.set(self, value)
end

#to_sObject



59
60
61
# File 'lib/logstash/filters/math_calculation_elements.rb', line 59

def to_s
  @description
end