Class: Tapioca::TypeTemplate

Inherits:
T::Types::TypeTemplate
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/tapioca/sorbet_ext/generic_name_patch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(variance, fixed, lower, upper) ⇒ TypeTemplate

Returns a new instance of TypeTemplate.



112
113
114
115
116
117
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 112

def initialize(variance, fixed, lower, upper)
  super(variance)
  @fixed = fixed
  @lower = lower
  @upper = upper
end

Instance Attribute Details

#fixedObject (readonly)

Returns the value of attribute fixed.



109
110
111
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 109

def fixed
  @fixed
end

#lowerObject (readonly)

Returns the value of attribute lower.



109
110
111
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 109

def lower
  @lower
end

#nameObject

Returns the value of attribute name.



106
107
108
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 106

def name
  @name
end

#upperObject (readonly)

Returns the value of attribute upper.



109
110
111
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 109

def upper
  @upper
end

Instance Method Details

#serializeObject



120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 120

def serialize
  parts = []
  parts << ":#{@variance}" unless @variance == :invariant
  parts << "fixed: #{@fixed}" if @fixed
  parts << "lower: #{@lower}" unless @lower == T.untyped
  parts << "upper: #{@upper}" unless @upper == BasicObject

  parameters = parts.join(", ")

  serialized = +"type_template"
  serialized << "(#{parameters})" unless parameters.empty?
  serialized
end