123456789_123456789_123456789_123456789_123456789_

Class: RBS::BuiltinNames::Name

Relationships & Source Files
Inherits: Object
Defined in: lib/rbs/builtin_names.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name:) ⇒ Name

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 8

def initialize(name:)
  @name = name
end

Class Method Details

.define(name, namespace: Namespace.root)

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 32

def self.define(name, namespace: Namespace.root)
  new(name: TypeName.new(name: name, namespace: namespace))
end

Instance Attribute Details

#name (readonly)

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 6

attr_reader :name

Instance Method Details

#instance_type(*args)

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 16

def instance_type(*args)
  Types::ClassInstance.new(name: name, args: args, location: nil)
end

#instance_type?(type) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 20

def instance_type?(type)
  type.is_a?(Types::ClassInstance) && type.name == name
end

#singleton_type

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 24

def singleton_type
  @singleton_type ||= Types::ClassSingleton.new(name: name, location: nil)
end

#singleton_type?(type) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 28

def singleton_type?(type)
  type.is_a?(Types::ClassSingleton) && type.name == name
end

#to_s

[ GitHub ]

  
# File 'lib/rbs/builtin_names.rb', line 12

def to_s
  name.to_s
end