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.



444
445
446
447
448
449
# File 'lib/rbs/ast/declarations.rb', line 444

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.



442
443
444
# File 'lib/rbs/ast/declarations.rb', line 442

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



441
442
443
# File 'lib/rbs/ast/declarations.rb', line 441

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



440
441
442
# File 'lib/rbs/ast/declarations.rb', line 440

def type
  @type
end

Instance Method Details

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



451
452
453
454
455
# File 'lib/rbs/ast/declarations.rb', line 451

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



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

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