Class: TRuby::IR::GenericType

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

Overview

Generic type (Array<String>, Map<K, V>)

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(base:, type_args: [], **opts) ⇒ GenericType

Returns a new instance of GenericType.



549
550
551
552
553
# File 'lib/t_ruby/ir.rb', line 549

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

Instance Attribute Details

#baseObject

Returns the value of attribute base.



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

def base
  @base
end

#type_argsObject

Returns the value of attribute type_args.



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

def type_args
  @type_args
end

Instance Method Details

#to_rbsObject



555
556
557
# File 'lib/t_ruby/ir.rb', line 555

def to_rbs
  "#{@base}[#{@type_args.map(&:to_rbs).join(", ")}]"
end

#to_trbObject



559
560
561
# File 'lib/t_ruby/ir.rb', line 559

def to_trb
  "#{@base}<#{@type_args.map(&:to_trb).join(", ")}>"
end