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

Inherits:
Base
  • 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.



397
398
399
400
401
402
403
# File 'lib/rbs/ast/declarations.rb', line 397

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.



393
394
395
# File 'lib/rbs/ast/declarations.rb', line 393

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



395
396
397
# File 'lib/rbs/ast/declarations.rb', line 395

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



394
395
396
# File 'lib/rbs/ast/declarations.rb', line 394

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



391
392
393
# File 'lib/rbs/ast/declarations.rb', line 391

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



392
393
394
# File 'lib/rbs/ast/declarations.rb', line 392

def type
  @type
end

Instance Method Details

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



405
406
407
408
409
# File 'lib/rbs/ast/declarations.rb', line 405

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

#hashObject



413
414
415
# File 'lib/rbs/ast/declarations.rb', line 413

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

#to_json(*a) ⇒ Object



417
418
419
420
421
422
423
424
425
426
# File 'lib/rbs/ast/declarations.rb', line 417

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