Class: TRuby::IR::UnionType

Inherits:
TypeNode show all
Defined in:
lib/t_ruby/ir.rb

Overview

Union type (String | Integer | nil)

Instance Attribute Summary collapse

Attributes inherited from Node

#location, #metadata, #type_info

Instance Method Summary collapse

Methods inherited from Node

#accept, #children, #transform

Constructor Details

#initialize(types: [], **opts) ⇒ UnionType

Returns a new instance of UnionType.



538
539
540
541
# File 'lib/t_ruby/ir.rb', line 538

def initialize(types: [], **opts)
  super(**opts)
  @types = types
end

Instance Attribute Details

#typesObject

Returns the value of attribute types.



536
537
538
# File 'lib/t_ruby/ir.rb', line 536

def types
  @types
end

Instance Method Details

#to_rbsObject



543
544
545
# File 'lib/t_ruby/ir.rb', line 543

def to_rbs
  @types.map(&:to_rbs).join(" | ")
end

#to_trbObject



547
548
549
# File 'lib/t_ruby/ir.rb', line 547

def to_trb
  @types.map(&:to_trb).join(" | ")
end