Class: Yoda::Typing::Types::InstanceType

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
RbsTypeWrapperInterface
Defined in:
lib/yoda/typing/types/instance_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RbsTypeWrapperInterface

#environment

Constructor Details

#initialize(singleton_type) ⇒ InstanceType

Returns a new instance of InstanceType.

Parameters:



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

def initialize(singleton_type)
  @singleton_type = singleton_type
end

Instance Attribute Details

#singleton_typeRbsTypeWrapperInterface (readonly)



12
# File 'lib/yoda/typing/types/instance_type.rb', line 12

delegate environment: :singleton_type

Instance Method Details

#instance_typeInstanceType

Returns:



33
34
35
# File 'lib/yoda/typing/types/instance_type.rb', line 33

def instance_type
  InstanceType.new(self)
end

#klassStore::Objects::Base

Deprecated.

Use #value to access referred objects.



39
40
41
# File 'lib/yoda/typing/types/instance_type.rb', line 39

def klass
  value.referred_objects.first
end

#pretty_print(pp) ⇒ Object

Parameters:

  • pp (PP)


49
50
51
52
53
54
55
# File 'lib/yoda/typing/types/instance_type.rb', line 49

def pretty_print(pp)
  pp.object_group(self) do
    pp.breakable
    pp.text "@rbs_type="
    pp.pp rbs_type.to_s
  end
end

#rbs_typeRBS::Types::t

Returns:

  • (RBS::Types::t)


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

def rbs_type
  @rbs_type ||= make_instance(singleton_type.rbs_type)
end

#to_sString

Returns:

  • (String)


44
45
46
# File 'lib/yoda/typing/types/instance_type.rb', line 44

def to_s
  rbs_type.to_s
end

#valueModel::Values::Base

Returns:



28
29
30
# File 'lib/yoda/typing/types/instance_type.rb', line 28

def value
  @value ||= singleton_type.value.instance_value
end