Class: DrgDSL::Ast::UnaryCondition

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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.

Parameters:

  • op (String)


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

#conditionObject (readonly)

Returns the value of attribute condition.



273
274
275
# File 'lib/drgdsl/ast.rb', line 273

def condition
  @condition
end

#opObject (readonly)

Returns the value of attribute op.



273
274
275
# File 'lib/drgdsl/ast.rb', line 273

def op
  @op
end

Instance Method Details

#hashObject



290
291
292
# File 'lib/drgdsl/ast.rb', line 290

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

#to_hashObject



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