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.



302
303
304
305
# File 'lib/rbs/types.rb', line 302

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

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



307
308
309
# File 'lib/rbs/types.rb', line 307

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

#hashObject



313
314
315
# File 'lib/rbs/types.rb', line 313

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

#map_type_nameObject



330
331
332
333
334
335
# File 'lib/rbs/types.rb', line 330

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

#to_json(*a) ⇒ Object



320
321
322
# File 'lib/rbs/types.rb', line 320

def to_json(*a)
  { class: :alias, name: name, location: location }.to_json(*a)
end

#to_s(level = 0) ⇒ Object



324
325
326
# File 'lib/rbs/types.rb', line 324

def to_s(level = 0)
  name.to_s
end