Class: RBS::Types::ClassSingleton

Inherits:
Object
  • Object
show all
Includes:
EmptyEachType, NoFreeVariables, NoSubst
Defined in:
lib/rbs/types.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from EmptyEachType

#each_type

Methods included from NoSubst

#sub

Methods included from NoFreeVariables

#free_variables

Constructor Details

#initialize(name:, location:) ⇒ ClassSingleton

Returns a new instance of ClassSingleton.



150
151
152
153
# File 'lib/rbs/types.rb', line 150

def initialize(name:, location:)
  @name = name
  @location = location
end

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



148
149
150
# File 'lib/rbs/types.rb', line 148

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



147
148
149
# File 'lib/rbs/types.rb', line 147

def name
  @name
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



155
156
157
# File 'lib/rbs/types.rb', line 155

def ==(other)
  other.is_a?(ClassSingleton) && other.name == name
end

#hashObject



161
162
163
# File 'lib/rbs/types.rb', line 161

def hash
  self.class.hash ^ name.hash
end

#to_json(*a) ⇒ Object



168
169
170
# File 'lib/rbs/types.rb', line 168

def to_json(*a)
  { class: :class_singleton, name: name, location: location }.to_json(*a)
end

#to_s(level = 0) ⇒ Object



172
173
174
# File 'lib/rbs/types.rb', line 172

def to_s(level = 0)
  "singleton(#{name})"
end