Class: Gelauto::ArrayType

Inherits:
GenericType show all
Defined in:
lib/gelauto/array_type.rb

Instance Attribute Summary

Attributes inherited from GenericType

#generic_args, #ruby_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GenericType

#[]

Constructor Details

#initializeArrayType

Returns a new instance of ArrayType.



9
10
11
# File 'lib/gelauto/array_type.rb', line 9

def initialize
  super(::Array, [:elem])
end

Class Method Details

.introspect(obj) ⇒ Object



3
4
5
6
7
# File 'lib/gelauto/array_type.rb', line 3

def self.introspect(obj)
  new.tap do |var|
    obj.each { |elem| var[:elem] << Gelauto.introspect(elem) }
  end
end

Instance Method Details

#merge!(other) ⇒ Object



21
22
23
# File 'lib/gelauto/array_type.rb', line 21

def merge!(other)
  self[:elem].merge!(other[:elem])
end

#to_sigObject



13
14
15
16
17
18
19
# File 'lib/gelauto/array_type.rb', line 13

def to_sig
  if self[:elem].empty?
    'T::Array[T.untyped]'
  else
    "T::Array[#{self[:elem].to_sig}]"
  end
end