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.



389
390
391
392
393
394
# File 'lib/rbs/ast/declarations.rb', line 389

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.



387
388
389
# File 'lib/rbs/ast/declarations.rb', line 387

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



386
387
388
# File 'lib/rbs/ast/declarations.rb', line 386

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



384
385
386
# File 'lib/rbs/ast/declarations.rb', line 384

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



385
386
387
# File 'lib/rbs/ast/declarations.rb', line 385

def type
  @type
end

Instance Method Details

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



396
397
398
399
400
# File 'lib/rbs/ast/declarations.rb', line 396

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

#hashObject



404
405
406
# File 'lib/rbs/ast/declarations.rb', line 404

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

#to_json(state = _ = nil) ⇒ Object



408
409
410
411
412
413
414
415
416
# File 'lib/rbs/ast/declarations.rb', line 408

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