Class: DrgDSL::Ast::DateExpression

Inherits:
Object
  • Object
show all
Includes:
Node
Defined in:
lib/drgdsl/ast.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#==, #accept, included, #mdc_equality?, node_classes, #pretty_print, #sep_equality?, type, #type

Constructor Details

#initialize(left_variable:, right_variable: nil, left_condition:, right_condition: nil, comparison:, opd:) ⇒ DateExpression

Returns a new instance of DateExpression.

Parameters:

  • opd (String)

    E.g. “opd4” => “mind. 4 erfüllen” query



380
381
382
383
384
385
386
387
388
389
390
391
392
393
# File 'lib/drgdsl/ast.rb', line 380

def initialize(left_variable:,
               right_variable: nil,
               left_condition:,
               right_condition: nil,
               comparison:,
               opd:)

  @left_variable = left_variable
  @right_variable = right_variable
  @left_condition = left_condition
  @right_condition = right_condition
  @comparison = comparison
  @opd = opd.to_s.strip.upcase
end

Instance Attribute Details

#comparisonObject (readonly)

Returns the value of attribute comparison.



372
373
374
# File 'lib/drgdsl/ast.rb', line 372

def comparison
  @comparison
end

#left_conditionObject (readonly)

Returns the value of attribute left_condition.



372
373
374
# File 'lib/drgdsl/ast.rb', line 372

def left_condition
  @left_condition
end

#left_variableObject (readonly)

Returns the value of attribute left_variable.



372
373
374
# File 'lib/drgdsl/ast.rb', line 372

def left_variable
  @left_variable
end

#opdObject (readonly)

Returns the value of attribute opd.



372
373
374
# File 'lib/drgdsl/ast.rb', line 372

def opd
  @opd
end

#right_conditionObject (readonly)

Returns the value of attribute right_condition.



372
373
374
# File 'lib/drgdsl/ast.rb', line 372

def right_condition
  @right_condition
end

#right_variableObject (readonly)

Returns the value of attribute right_variable.



372
373
374
# File 'lib/drgdsl/ast.rb', line 372

def right_variable
  @right_variable
end

Instance Method Details

#hashObject



408
409
410
411
412
413
414
415
416
417
418
# File 'lib/drgdsl/ast.rb', line 408

def hash
  @hash ||= [
    type,
    left_variable,
    right_variable,
    left_condition,
    right_condition,
    comparison,
    opd
  ].hash
end

#to_hashObject



395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/drgdsl/ast.rb', line 395

def to_hash
  {
    opd: {
      var: opd,
      left_var: left_variable.to_hash,
      left_condition: left_condition.to_hash,
      right_var: right_variable&.to_hash,
      right_condition: right_condition&.to_hash,
      comparison: comparison.to_hash
    }
  }
end