Class: Skit::JsonSchema::Definitions::TuplePropertyType

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/skit/json_schema/definitions/tuple_property_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(item_types:, nullable: false) ⇒ TuplePropertyType

Returns a new instance of TuplePropertyType.



17
18
19
20
# File 'lib/skit/json_schema/definitions/tuple_property_type.rb', line 17

def initialize(item_types:, nullable: false)
  @item_types = item_types
  @nullable = nullable
end

Instance Attribute Details

#item_typesObject (readonly)

Returns the value of attribute item_types.



11
12
13
# File 'lib/skit/json_schema/definitions/tuple_property_type.rb', line 11

def item_types
  @item_types
end

#nullableObject (readonly)

Returns the value of attribute nullable.



14
15
16
# File 'lib/skit/json_schema/definitions/tuple_property_type.rb', line 14

def nullable
  @nullable
end

Instance Method Details

#to_sorbet_typeObject



23
24
25
26
# File 'lib/skit/json_schema/definitions/tuple_property_type.rb', line 23

def to_sorbet_type
  tuple_type = "[#{@item_types.map(&:to_sorbet_type).join(", ")}]"
  nullable ? "T.nilable(#{tuple_type})" : tuple_type
end

#with_nullableObject



29
30
31
# File 'lib/skit/json_schema/definitions/tuple_property_type.rb', line 29

def with_nullable
  TuplePropertyType.new(item_types: @item_types, nullable: true)
end