Class: RBS::BuiltinNames::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/builtin_names.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:) ⇒ Name

Returns a new instance of Name.



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

def initialize(name:)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

.define(name, namespace: Namespace.root) ⇒ Object



32
33
34
# 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 Method Details

#instance_type(*args) ⇒ Object



16
17
18
# 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

Returns:

  • (Boolean)


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

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

#singleton_typeObject



24
25
26
# 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

Returns:

  • (Boolean)


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

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

#to_sObject



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

def to_s
  name.to_s
end