Class: Fluent::FilterWhere::Parser::LogicalOpExp

Inherits:
Exp
  • Object
show all
Defined in:
lib/fluent/plugin/filter_where/parser/exp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(left, right, operator) ⇒ LogicalOpExp

Returns a new instance of LogicalOpExp.

Parameters:

  • left (ParserLiteral)
  • right (ParserLiteral)
  • operator (Symbol)


143
144
145
146
147
# File 'lib/fluent/plugin/filter_where/parser/exp.rb', line 143

def initialize(left, right, operator)
  @left = left
  @right = right
  @operator = operator
end

Instance Attribute Details

#leftObject (readonly)

Returns the value of attribute left.



138
139
140
# File 'lib/fluent/plugin/filter_where/parser/exp.rb', line 138

def left
  @left
end

#operatorObject (readonly)

Returns the value of attribute operator.



138
139
140
# File 'lib/fluent/plugin/filter_where/parser/exp.rb', line 138

def operator
  @operator
end

#rightObject (readonly)

Returns the value of attribute right.



138
139
140
# File 'lib/fluent/plugin/filter_where/parser/exp.rb', line 138

def right
  @right
end

Instance Method Details

#eval(record) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/fluent/plugin/filter_where/parser/exp.rb', line 149

def eval(record)
  l = left.eval(record)
  r = right.eval(record)
  case operator
  when :OR
    return l || r
  when :AND
    l && r
  else
    assert(false)
    false
  end
end