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.



364
365
366
367
368
369
370
371
# File 'lib/rbs/ast/members.rb', line 364

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.



360
361
362
# File 'lib/rbs/ast/members.rb', line 360

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



362
363
364
# File 'lib/rbs/ast/members.rb', line 362

def comment
  @comment
end

#kindObject (readonly)

Returns the value of attribute kind.



359
360
361
# File 'lib/rbs/ast/members.rb', line 359

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



361
362
363
# File 'lib/rbs/ast/members.rb', line 361

def location
  @location
end

#new_nameObject (readonly)

Returns the value of attribute new_name.



357
358
359
# File 'lib/rbs/ast/members.rb', line 357

def new_name
  @new_name
end

#old_nameObject (readonly)

Returns the value of attribute old_name.



358
359
360
# File 'lib/rbs/ast/members.rb', line 358

def old_name
  @old_name
end

Instance Method Details

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



373
374
375
376
377
378
# File 'lib/rbs/ast/members.rb', line 373

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

#hashObject



382
383
384
# File 'lib/rbs/ast/members.rb', line 382

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

#instance?Boolean

Returns:

  • (Boolean)


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

def instance?
  kind == :instance
end

#singleton?Boolean

Returns:

  • (Boolean)


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

def singleton?
  kind == :singleton
end

#to_json(state = _ = nil) ⇒ Object



386
387
388
389
390
391
392
393
394
395
396
# File 'lib/rbs/ast/members.rb', line 386

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