Class: RBSProtobuf::Name::Class

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs_protobuf/name.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Class

Returns a new instance of Class.



6
7
8
9
# File 'lib/rbs_protobuf/name.rb', line 6

def initialize(name)
  raise unless name.class?
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/rbs_protobuf/name.rb', line 4

def name
  @name
end

Instance Method Details

#instance_type(*args) ⇒ Object Also known as: []



11
12
13
# File 'lib/rbs_protobuf/name.rb', line 11

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

#instance_type?(t) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/rbs_protobuf/name.rb', line 21

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

#singleton_typeObject



17
18
19
# File 'lib/rbs_protobuf/name.rb', line 17

def singleton_type
  RBS::Types::ClassSingleton.new(name: name, location: nil)
end

#singleton_type?(t) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/rbs_protobuf/name.rb', line 25

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

#super_class(*args) ⇒ Object



29
30
31
# File 'lib/rbs_protobuf/name.rb', line 29

def super_class(*args)
  RBS::AST::Declarations::Class::Super.new(name: name, args: args, location: nil)
end