Class: RBS::Types::Alias

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:) ⇒ Alias

Returns a new instance of Alias.



300
301
302
303
# File 'lib/rbs/types.rb', line 300

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



297
298
299
# File 'lib/rbs/types.rb', line 297

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



298
299
300
# File 'lib/rbs/types.rb', line 298

def name
  @name
end

Instance Method Details

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



305
306
307
# File 'lib/rbs/types.rb', line 305

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

#hashObject



311
312
313
# File 'lib/rbs/types.rb', line 311

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

#map_type_nameObject



328
329
330
331
332
333
# File 'lib/rbs/types.rb', line 328

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

#to_json(state = _ = nil) ⇒ Object



318
319
320
# File 'lib/rbs/types.rb', line 318

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

#to_s(level = 0) ⇒ Object



322
323
324
# File 'lib/rbs/types.rb', line 322

def to_s(level = 0)
  name.to_s
end