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.



266
267
268
269
# File 'lib/rbs/types.rb', line 266

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

Instance Attribute Details

#locationObject (readonly)

Returns the value of attribute location.



263
264
265
# File 'lib/rbs/types.rb', line 263

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



264
265
266
# File 'lib/rbs/types.rb', line 264

def name
  @name
end

Instance Method Details

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



271
272
273
# File 'lib/rbs/types.rb', line 271

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

#hashObject



277
278
279
# File 'lib/rbs/types.rb', line 277

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

#to_json(*a) ⇒ Object



284
285
286
# File 'lib/rbs/types.rb', line 284

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

#to_s(level = 0) ⇒ Object



288
289
290
# File 'lib/rbs/types.rb', line 288

def to_s(level = 0)
  name.to_s
end