Class: DrgDSL::Ast::UnaryCondition
- Inherits:
-
Object
- Object
- DrgDSL::Ast::UnaryCondition
- Includes:
- Node
- Defined in:
- lib/drgdsl/ast.rb
Overview
Has a certain operator (i.e. not / different) and a condition
“not < 3”
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#op ⇒ Object
readonly
Returns the value of attribute op.
Instance Method Summary collapse
- #hash ⇒ Object
-
#initialize(op:, condition:) ⇒ UnaryCondition
constructor
A new instance of UnaryCondition.
- #to_hash ⇒ Object
Methods included from Node
#==, #accept, included, #mdc_equality?, node_classes, #pretty_print, #sep_equality?, type, #type
Constructor Details
#initialize(op:, condition:) ⇒ UnaryCondition
Returns a new instance of UnaryCondition.
276 277 278 279 |
# File 'lib/drgdsl/ast.rb', line 276 def initialize(op:, condition:) @op = op.to_s.downcase @condition = condition end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
273 274 275 |
# File 'lib/drgdsl/ast.rb', line 273 def condition @condition end |
#op ⇒ Object (readonly)
Returns the value of attribute op.
273 274 275 |
# File 'lib/drgdsl/ast.rb', line 273 def op @op end |
Instance Method Details
#hash ⇒ Object
290 291 292 |
# File 'lib/drgdsl/ast.rb', line 290 def hash @hash ||= [type, op, condition].hash end |
#to_hash ⇒ Object
281 282 283 284 285 286 287 288 |
# File 'lib/drgdsl/ast.rb', line 281 def to_hash { unary_condition: { op: op, condition: condition.to_hash } } end |