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.



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

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



159
160
161
# File 'lib/rbs/types.rb', line 159

def name
  @name
end

Instance Method Details

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



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

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

#hashObject



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

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

#map_type_nameObject



190
191
192
193
194
195
# File 'lib/rbs/types.rb', line 190

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

#to_json(state = _ = nil) ⇒ Object



180
181
182
# File 'lib/rbs/types.rb', line 180

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

#to_s(level = 0) ⇒ Object



184
185
186
# File 'lib/rbs/types.rb', line 184

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