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.



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

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.



294
295
296
# File 'lib/rbs/ast/declarations.rb', line 294

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



296
297
298
# File 'lib/rbs/ast/declarations.rb', line 296

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



295
296
297
# File 'lib/rbs/ast/declarations.rb', line 295

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



292
293
294
# File 'lib/rbs/ast/declarations.rb', line 292

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



293
294
295
# File 'lib/rbs/ast/declarations.rb', line 293

def type
  @type
end

Instance Method Details

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



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

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

#hashObject



314
315
316
# File 'lib/rbs/ast/declarations.rb', line 314

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

#to_json(*a) ⇒ Object



318
319
320
321
322
323
324
325
326
327
# File 'lib/rbs/ast/declarations.rb', line 318

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