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.



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

def initialize(name:)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Class Method Details

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



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

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

Instance Method Details

#instance_type(*args) ⇒ Object



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

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

#instance_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#singleton_typeObject



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

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

#singleton_type?(type) ⇒ Boolean

Returns:

  • (Boolean)


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

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

#to_sObject



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

def to_s
  name.to_s
end