Class: Tapioca::TypeMember

Inherits:
T::Types::TypeMember
  • 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) ⇒ TypeMember

Returns a new instance of TypeMember.


79
80
81
82
83
84
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 79

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.


76
77
78
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 76

def fixed
  @fixed
end

#lowerObject (readonly)

Returns the value of attribute lower.


76
77
78
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 76

def lower
  @lower
end

#nameObject

Returns the value of attribute name.


73
74
75
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 73

def name
  @name
end

#upperObject (readonly)

Returns the value of attribute upper.


76
77
78
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 76

def upper
  @upper
end

Instance Method Details

#serializeObject


87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/tapioca/sorbet_ext/generic_name_patch.rb', line 87

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_member"
  serialized << "(#{parameters})" unless parameters.empty?
  serialized
end