123456789_123456789_123456789_123456789_123456789_

Class: RBS::Types::ClassSingleton

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
Inherits: Object
Defined in: lib/rbs/types.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name:, location:) ⇒ ClassSingleton

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 171

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

Instance Attribute Details

#location (readonly)

[ GitHub ]

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

attr_reader :location

#name (readonly)

[ GitHub ]

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

attr_reader :name

Instance Method Details

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

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 176

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

#eql?(other)

Alias for #==.

[ GitHub ]

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

alias eql? ==

#hash

[ GitHub ]

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

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

#map_type_name

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 199

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

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 189

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

#to_s(level = 0)

[ GitHub ]

  
# File 'lib/rbs/types.rb', line 193

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