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

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



372
373
374
375
376
377
# File 'lib/rbs/ast/declarations.rb', line 372

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.



370
371
372
# File 'lib/rbs/ast/declarations.rb', line 370

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



369
370
371
# File 'lib/rbs/ast/declarations.rb', line 369

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



367
368
369
# File 'lib/rbs/ast/declarations.rb', line 367

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



368
369
370
# File 'lib/rbs/ast/declarations.rb', line 368

def type
  @type
end

Instance Method Details

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



379
380
381
382
383
# File 'lib/rbs/ast/declarations.rb', line 379

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

#hashObject



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

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

#to_json(*a) ⇒ Object



391
392
393
394
395
396
397
398
399
# File 'lib/rbs/ast/declarations.rb', line 391

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