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, #map_type

Methods included from NoSubst

#sub

Methods included from NoFreeVariables

#free_variables

Constructor Details

#initialize(name:, location:) ⇒ ClassSingleton

Returns a new instance of ClassSingleton.



206
207
208
209
# File 'lib/rbs/types.rb', line 206

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



204
205
206
# File 'lib/rbs/types.rb', line 204

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



203
204
205
# File 'lib/rbs/types.rb', line 203

def name
  @name
end

Instance Method Details

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



211
212
213
# File 'lib/rbs/types.rb', line 211

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

#has_classish_type?Boolean

Returns:

  • (Boolean)


245
246
247
# File 'lib/rbs/types.rb', line 245

def has_classish_type?
  false
end

#has_self_type?Boolean

Returns:

  • (Boolean)


241
242
243
# File 'lib/rbs/types.rb', line 241

def has_self_type?
  false
end

#hashObject



217
218
219
# File 'lib/rbs/types.rb', line 217

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

#map_type_nameObject



234
235
236
237
238
239
# File 'lib/rbs/types.rb', line 234

def map_type_name(&)
  ClassSingleton.new(
    name: yield(name, location, self),
    location: location
  )
end

#to_json(state = _ = nil) ⇒ Object



224
225
226
# File 'lib/rbs/types.rb', line 224

def to_json(state = _ = nil)
  { class: :class_singleton, name: name, location: location }.to_json(state)
end

#to_s(level = 0) ⇒ Object



228
229
230
# File 'lib/rbs/types.rb', line 228

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

#with_nonreturn_void?Boolean

Returns:

  • (Boolean)


249
250
251
# File 'lib/rbs/types.rb', line 249

def with_nonreturn_void?
  false
end