Class: RBS::AST::Declarations::Global

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:, location:, comment:) ⇒ Global

Returns a new instance of Global.



465
466
467
468
469
470
# File 'lib/rbs/ast/declarations.rb', line 465

def initialize(name:, type:, location:, comment:)
  @name = name
  @type = type
  @location = location
  @comment = comment
end

Instance Attribute Details

#commentObject (readonly)

Returns the value of attribute comment.



463
464
465
# File 'lib/rbs/ast/declarations.rb', line 463

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



462
463
464
# File 'lib/rbs/ast/declarations.rb', line 462

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



460
461
462
# File 'lib/rbs/ast/declarations.rb', line 460

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



461
462
463
# File 'lib/rbs/ast/declarations.rb', line 461

def type
  @type
end

Instance Method Details

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



472
473
474
475
476
# File 'lib/rbs/ast/declarations.rb', line 472

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

#hashObject



480
481
482
# File 'lib/rbs/ast/declarations.rb', line 480

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

#to_json(*a) ⇒ Object



484
485
486
487
488
489
490
491
492
# File 'lib/rbs/ast/declarations.rb', line 484

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