Class: RBS::AST::Declarations::Alias

Inherits:
Object
  • Object
show all
Defined in:
lib/rbs/ast/declarations.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, type:, annotations:, location:, comment:) ⇒ Alias

Returns a new instance of Alias.



290
291
292
293
294
295
296
# File 'lib/rbs/ast/declarations.rb', line 290

def initialize(name:, type:, annotations:, location:, comment:)
  @name = name
  @type = type
  @annotations = annotations
  @location = location
  @comment = comment
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



286
287
288
# File 'lib/rbs/ast/declarations.rb', line 286

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



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

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



287
288
289
# File 'lib/rbs/ast/declarations.rb', line 287

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



285
286
287
# File 'lib/rbs/ast/declarations.rb', line 285

def type
  @type
end

Instance Method Details

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



298
299
300
301
302
# File 'lib/rbs/ast/declarations.rb', line 298

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

#hashObject



306
307
308
# File 'lib/rbs/ast/declarations.rb', line 306

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

#to_json(*a) ⇒ Object



310
311
312
313
314
315
316
317
318
319
# File 'lib/rbs/ast/declarations.rb', line 310

def to_json(*a)
  {
    declaration: :alias,
    name: name,
    type: type,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(*a)
end