Class: Yoda::Typing::Types::Instance

Inherits:
Base
  • Object
show all
Defined in:
lib/yoda/typing/types/instance.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#reference?

Constructor Details

#initialize(klass:) ⇒ Instance

Returns a new instance of Instance.

Parameters:



9
10
11
# File 'lib/yoda/typing/types/instance.rb', line 9

def initialize(klass:)
  @klass = klass
end

Instance Attribute Details

#klassStor::Objects::NamespaceObject (readonly)

Returns:

  • (Stor::Objects::NamespaceObject)


6
7
8
# File 'lib/yoda/typing/types/instance.rb', line 6

def klass
  @klass
end

Instance Method Details

#to_expressionObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/yoda/typing/types/instance.rb', line 13

def to_expression
  case klass.kind
  when :meta_class
    Model::TypeExpressions::ModuleType.new(klass.path)
  when :class, :module
    Model::TypeExpressions::InstanceType.new(klass.path)
  else
    fail NotImplementedError
  end
end

#to_type_stringObject



24
25
26
# File 'lib/yoda/typing/types/instance.rb', line 24

def to_type_string
  klass.path
end