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

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



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

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.



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

def annotations
  @annotations
end

#commentObject (readonly)

Returns the value of attribute comment.



316
317
318
# File 'lib/rbs/ast/members.rb', line 316

def comment
  @comment
end

#kindObject (readonly)

Returns the value of attribute kind.



313
314
315
# File 'lib/rbs/ast/members.rb', line 313

def kind
  @kind
end

#locationObject (readonly)

Returns the value of attribute location.



315
316
317
# File 'lib/rbs/ast/members.rb', line 315

def location
  @location
end

#new_nameObject (readonly)

Returns the value of attribute new_name.



311
312
313
# File 'lib/rbs/ast/members.rb', line 311

def new_name
  @new_name
end

#old_nameObject (readonly)

Returns the value of attribute old_name.



312
313
314
# File 'lib/rbs/ast/members.rb', line 312

def old_name
  @old_name
end

Instance Method Details

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



327
328
329
330
331
332
# File 'lib/rbs/ast/members.rb', line 327

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

#hashObject



336
337
338
# File 'lib/rbs/ast/members.rb', line 336

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

#instance?Boolean

Returns:

  • (Boolean)


352
353
354
# File 'lib/rbs/ast/members.rb', line 352

def instance?
  kind == :instance
end

#singleton?Boolean

Returns:

  • (Boolean)


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

def singleton?
  kind == :singleton
end

#to_json(*a) ⇒ Object



340
341
342
343
344
345
346
347
348
349
350
# File 'lib/rbs/ast/members.rb', line 340

def to_json(*a)
  {
    member: :alias,
    new_name: new_name,
    old_name: old_name,
    kind: kind,
    annotations: annotations,
    location: location,
    comment: comment
  }.to_json(*a)
end