Class: RBS::AST::Declarations::Constant
- Inherits:
-
Object
- Object
- RBS::AST::Declarations::Constant
- Defined in:
- lib/rbs/ast/declarations.rb
Instance Attribute Summary collapse
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name:, type:, location:, comment:) ⇒ Constant
constructor
A new instance of Constant.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(name:, type:, location:, comment:) ⇒ Constant
Returns a new instance of Constant.
336 337 338 339 340 341 |
# File 'lib/rbs/ast/declarations.rb', line 336 def initialize(name:, type:, location:, comment:) @name = name @type = type @location = location @comment = comment end |
Instance Attribute Details
#comment ⇒ Object (readonly)
Returns the value of attribute comment.
334 335 336 |
# File 'lib/rbs/ast/declarations.rb', line 334 def comment @comment end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
333 334 335 |
# File 'lib/rbs/ast/declarations.rb', line 333 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
331 332 333 |
# File 'lib/rbs/ast/declarations.rb', line 331 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
332 333 334 |
# File 'lib/rbs/ast/declarations.rb', line 332 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
343 344 345 346 347 |
# File 'lib/rbs/ast/declarations.rb', line 343 def ==(other) other.is_a?(Constant) && other.name == name && other.type == type end |
#hash ⇒ Object
351 352 353 |
# File 'lib/rbs/ast/declarations.rb', line 351 def hash self.class.hash ^ name.hash ^ type.hash end |
#to_json(*a) ⇒ Object
355 356 357 358 359 360 361 362 363 |
# File 'lib/rbs/ast/declarations.rb', line 355 def to_json(*a) { declaration: :constant, name: name, type: type, location: location, comment: comment }.to_json(*a) end |