Class: TRuby::IR::CaseExpr

Inherits:
Node
  • Object
show all
Defined in:
lib/t_ruby/ir.rb

Overview

Case/when expression

Instance Attribute Summary collapse

Attributes inherited from Node

#location, #metadata, #type_info

Instance Method Summary collapse

Methods inherited from Node

#accept, #transform

Constructor Details

#initialize(subject: nil, when_clauses: [], else_clause: nil, **opts) ⇒ CaseExpr

Returns a new instance of CaseExpr.



285
286
287
288
289
290
# File 'lib/t_ruby/ir.rb', line 285

def initialize(subject: nil, when_clauses: [], else_clause: nil, **opts)
  super(**opts)
  @subject = subject
  @when_clauses = when_clauses
  @else_clause = else_clause
end

Instance Attribute Details

#else_clauseObject

Returns the value of attribute else_clause.



283
284
285
# File 'lib/t_ruby/ir.rb', line 283

def else_clause
  @else_clause
end

#subjectObject

Returns the value of attribute subject.



283
284
285
# File 'lib/t_ruby/ir.rb', line 283

def subject
  @subject
end

#when_clausesObject

Returns the value of attribute when_clauses.



283
284
285
# File 'lib/t_ruby/ir.rb', line 283

def when_clauses
  @when_clauses
end

Instance Method Details

#childrenObject



292
293
294
# File 'lib/t_ruby/ir.rb', line 292

def children
  ([@subject, @else_clause] + @when_clauses).compact
end