123456789_123456789_123456789_123456789_123456789_

Class: RBS::AST::Declarations::Constant

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Base
Instance Chain:
self, Base
Inherits: RBS::AST::Declarations::Base
Defined in: lib/rbs/ast/declarations.rb

Class Method Summary

Instance Attribute Summary

Instance Method Summary

Constructor Details

.new(name:, type:, location:, comment:) ⇒ Constant

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 317

def initialize(name:, type:, location:, comment:)
  @name = name
  @type = type
  @location = location
  @comment = comment
end

Instance Attribute Details

#comment (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 315

attr_reader :comment

#location (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 314

attr_reader :location

#name (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 312

attr_reader :name

#type (readonly)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 313

attr_reader :type

Instance Method Details

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

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 324

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

#eql?(other)

Alias for #==.

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 330

alias eql? ==

#hash

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 332

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

#to_json(state = _ = nil)

[ GitHub ]

  
# File 'lib/rbs/ast/declarations.rb', line 336

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