Class: Yoda::Typing::Types::Type

Inherits:
Object
  • Object
show all
Includes:
RbsTypeWrapperInterface
Defined in:
lib/yoda/typing/types/type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment:, rbs_type:) ⇒ Type

Returns a new instance of Type.

Parameters:



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

def initialize(environment:, rbs_type:)
  @environment = environment
  @rbs_type = rbs_type
end

Instance Attribute Details

#environmentModel::Environment (readonly)

Returns:



10
11
12
# File 'lib/yoda/typing/types/type.rb', line 10

def environment
  @environment
end

#rbs_typeRBS::Types::t (readonly)

Returns:

  • (RBS::Types::t)


13
14
15
# File 'lib/yoda/typing/types/type.rb', line 13

def rbs_type
  @rbs_type
end

Instance Method Details

#instance_typeInstanceType

Returns:



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

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/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/type.rb', line 49

def pretty_print(pp)
  pp.object_group(self) do
    pp.breakable
    pp.text "type:"
    pp.pp rbs_type.to_s
  end
end

#singleton_typeSingletonType

Returns:



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

def singleton_type
  SingletonType.new(self)
end

#to_sString

Returns:

  • (String)


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

def to_s
  rbs_type.to_s
end

#valueModel::Values::Base

Returns:



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

def value
  @value ||= environment.resolve_value_by_rbs_type(rbs_type)
end