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.



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

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



201
202
203
# File 'lib/rbs/types.rb', line 201

def name
  @name
end

Instance Method Details

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



209
210
211
# File 'lib/rbs/types.rb', line 209

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

#has_classish_type?Boolean

Returns:

  • (Boolean)


243
244
245
# File 'lib/rbs/types.rb', line 243

def has_classish_type?
  false
end

#has_self_type?Boolean

Returns:

  • (Boolean)


239
240
241
# File 'lib/rbs/types.rb', line 239

def has_self_type?
  false
end

#hashObject



215
216
217
# File 'lib/rbs/types.rb', line 215

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

#map_type_nameObject



232
233
234
235
236
237
# File 'lib/rbs/types.rb', line 232

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

#to_json(state = _ = nil) ⇒ Object



222
223
224
# File 'lib/rbs/types.rb', line 222

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

#to_s(level = 0) ⇒ Object



226
227
228
# File 'lib/rbs/types.rb', line 226

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

#with_nonreturn_void?Boolean

Returns:

  • (Boolean)


247
248
249
# File 'lib/rbs/types.rb', line 247

def with_nonreturn_void?
  false
end