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.



351
352
353
354
355
356
# File 'lib/rbs/ast/declarations.rb', line 351

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.



349
350
351
# File 'lib/rbs/ast/declarations.rb', line 349

def comment
  @comment
end

#locationObject (readonly)

Returns the value of attribute location.



348
349
350
# File 'lib/rbs/ast/declarations.rb', line 348

def location
  @location
end

#nameObject (readonly)

Returns the value of attribute name.



346
347
348
# File 'lib/rbs/ast/declarations.rb', line 346

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



347
348
349
# File 'lib/rbs/ast/declarations.rb', line 347

def type
  @type
end

Instance Method Details

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



358
359
360
361
362
# File 'lib/rbs/ast/declarations.rb', line 358

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

#hashObject



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

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

#to_json(state = _ = nil) ⇒ Object



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

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