Class: DrgDSL::Ast::BasicExpression

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

Overview

A BasicExpression consists of a variable and a condition (because every variant of condition has a variable)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Node

#==, #accept, included, node_classes, #pretty_print, type, #type

Constructor Details

#initialize(variable:, condition:) ⇒ BasicExpression

Returns a new instance of BasicExpression.

Parameters:



217
218
219
220
# File 'lib/drgdsl/ast.rb', line 217

def initialize(variable:, condition:)
  @variable = variable
  @condition = condition
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



213
214
215
# File 'lib/drgdsl/ast.rb', line 213

def condition
  @condition
end

#variableObject (readonly)

Returns the value of attribute variable.



213
214
215
# File 'lib/drgdsl/ast.rb', line 213

def variable
  @variable
end

Instance Method Details

#hashObject



234
235
236
# File 'lib/drgdsl/ast.rb', line 234

def hash
  @hash ||= [type, variable, condition].hash
end

#mdc_equality?Boolean

Returns:

  • (Boolean)


222
223
224
# File 'lib/drgdsl/ast.rb', line 222

def mdc_equality?
  variable.name == "MDC" && condition.op == "="
end

#sep_equality?Boolean

Returns:

  • (Boolean)


226
227
228
# File 'lib/drgdsl/ast.rb', line 226

def sep_equality?
  variable.name == "SEP" && condition.op == "="
end

#to_hashObject



230
231
232
# File 'lib/drgdsl/ast.rb', line 230

def to_hash
  { basic: { var: variable.to_hash, condition: condition.to_hash } }
end