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, register) ⇒ RegisterElement

supports ‘get` and `set`



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

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

Instance Method Details

#get(event) ⇒ Object



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

def get(event)
  @register[@index] #log warning if nil
end

#inspectObject



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

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

#literal?Boolean

Returns:

  • (Boolean)


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

def literal?
  false
end

#set(value, event) ⇒ Object



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

def set(value, event)
  # raise usage error if called when position != 3 ??
  @register[@index] = value
end

#to_sObject



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

def to_s
  @description
end