Class: RBS::AST::Members::Alias

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(new_name:, old_name:, kind:, annotations:, location:, comment:) ⇒ Alias

Returns a new instance of Alias.



405
406
407
408
409
410
411
412
# File 'lib/rbs/ast/members.rb', line 405

def initialize(new_name:, old_name:, kind:, annotations:, location:, comment:)
  @new_name = new_name
  @old_name = old_name
  @kind = kind
  @annotations = annotations
  @location = location
  @comment = comment
end

Instance Attribute Details

#annotationsObject (readonly)

Returns the value of attribute annotations.



401
402
403
# File 'lib/rbs/ast/members.rb', line 401

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



403
404
405
# File 'lib/rbs/ast/members.rb', line 403

def comment
  @comment
end

#kindObject (readonly)

Returns the value of attribute kind.



400
401
402
# File 'lib/rbs/ast/members.rb', line 400

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



402
403
404
# File 'lib/rbs/ast/members.rb', line 402

def location
  @location
end

#new_nameObject (readonly)

Returns the value of attribute new_name.



398
399
400
# File 'lib/rbs/ast/members.rb', line 398

def new_name
  @new_name
end

#old_nameObject (readonly)

Returns the value of attribute old_name.



399
400
401
# File 'lib/rbs/ast/members.rb', line 399

def old_name
  @old_name
end

Instance Method Details

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



414
415
416
417
418
419
# File 'lib/rbs/ast/members.rb', line 414

def ==(other)
  other.is_a?(self.class) &&
    other.new_name == new_name &&
    other.old_name == old_name &&
    other.kind == kind
end

#hashObject



423
424
425
# File 'lib/rbs/ast/members.rb', line 423

def hash
  new_name.hash ^ old_name.hash ^ kind.hash
end

#instance?Boolean

Returns:

  • (Boolean)


439
440
441
# File 'lib/rbs/ast/members.rb', line 439

def instance?
  kind == :instance
end

#singleton?Boolean

Returns:

  • (Boolean)


443
444
445
# File 'lib/rbs/ast/members.rb', line 443

def singleton?
  kind == :singleton
end

#to_json(state = _ = nil) ⇒ Object



427
428
429
430
431
432
433
434
435
436
437
# File 'lib/rbs/ast/members.rb', line 427

def to_json(state = _ = nil)
  {
    member: :alias,
    new_name: new_name,
    old_name: old_name,
    kind: kind,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(state)
end