Class: DrgDSL::Ast::BasicExpression
- Inherits:
-
Object
- Object
- DrgDSL::Ast::BasicExpression
- 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
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#variable ⇒ Object
readonly
Returns the value of attribute variable.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(variable:, condition:) ⇒ BasicExpression
constructor
A new instance of BasicExpression.
- #mdc_equality? ⇒ Boolean
- #sep_equality? ⇒ Boolean
- #to_hash ⇒ Object
Methods included from Node
#==, #accept, included, node_classes, #pretty_print, type, #type
Constructor Details
#initialize(variable:, condition:) ⇒ BasicExpression
Returns a new instance of BasicExpression.
217 218 219 220 |
# File 'lib/drgdsl/ast.rb', line 217 def initialize(variable:, condition:) @variable = variable @condition = condition end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
213 214 215 |
# File 'lib/drgdsl/ast.rb', line 213 def condition @condition end |
#variable ⇒ Object (readonly)
Returns the value of attribute variable.
213 214 215 |
# File 'lib/drgdsl/ast.rb', line 213 def variable @variable end |
Instance Method Details
#hash ⇒ Object
234 235 236 |
# File 'lib/drgdsl/ast.rb', line 234 def hash @hash ||= [type, variable, condition].hash end |
#mdc_equality? ⇒ Boolean
222 223 224 |
# File 'lib/drgdsl/ast.rb', line 222 def mdc_equality? variable.name == "MDC" && condition.op == "=" end |
#sep_equality? ⇒ Boolean
226 227 228 |
# File 'lib/drgdsl/ast.rb', line 226 def sep_equality? variable.name == "SEP" && condition.op == "=" end |
#to_hash ⇒ Object
230 231 232 |
# File 'lib/drgdsl/ast.rb', line 230 def to_hash { basic: { var: variable.to_hash, condition: condition.to_hash } } end |