Class: Yoda::Typing::Types::Generic

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/typing/types/generic.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#reference?

Constructor Details

#initialize(base:, type_args:) ⇒ Generic

Returns a new instance of Generic.

Parameters:



13
14
15
16
# File 'lib/yoda/typing/types/generic.rb', line 13

def initialize(base:, type_args:)
  @base = base
  @type_args = type_args
end

Instance Attribute Details

#baseBase (readonly)

Returns:



6
7
8
# File 'lib/yoda/typing/types/generic.rb', line 6

def base
  @base
end

#type_argsArray<Base> (readonly)

Returns:



9
10
11
# File 'lib/yoda/typing/types/generic.rb', line 9

def type_args
  @type_args
end

Instance Method Details

#to_expressionObject



18
19
20
# File 'lib/yoda/typing/types/generic.rb', line 18

def to_expression
  base.to_expression
end

#to_type_stringObject



22
23
24
25
# File 'lib/yoda/typing/types/generic.rb', line 22

def to_type_string
  inner = type_args.map(&:to_type_string)
  "#{base.to_type_string}<#{inner.join(', ')}>"
end