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.



370
371
372
373
374
375
376
# File 'lib/rbs/ast/declarations.rb', line 370

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.



366
367
368
# File 'lib/rbs/ast/declarations.rb', line 366

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



368
369
370
# File 'lib/rbs/ast/declarations.rb', line 368

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



367
368
369
# File 'lib/rbs/ast/declarations.rb', line 367

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



364
365
366
# File 'lib/rbs/ast/declarations.rb', line 364

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



365
366
367
# File 'lib/rbs/ast/declarations.rb', line 365

def type
  @type
end

Instance Method Details

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



378
379
380
381
382
# File 'lib/rbs/ast/declarations.rb', line 378

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

#hashObject



386
387
388
# File 'lib/rbs/ast/declarations.rb', line 386

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

#to_json(state = _ = nil) ⇒ Object



390
391
392
393
394
395
396
397
398
399
# File 'lib/rbs/ast/declarations.rb', line 390

def to_json(state = _ = nil)
  {
    declaration: :alias,
    name: name,
    type: type,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(state)
end