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.



448
449
450
451
452
453
# File 'lib/rbs/ast/declarations.rb', line 448

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.



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

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



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

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

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



455
456
457
458
459
# File 'lib/rbs/ast/declarations.rb', line 455

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



467
468
469
470
471
472
473
474
475
# File 'lib/rbs/ast/declarations.rb', line 467

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