Class: 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.
393 394 395 396 397 398 |
# File 'lib/rbs/ast/declarations.rb', line 393 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.
391 392 393 |
# File 'lib/rbs/ast/declarations.rb', line 391 def comment @comment end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
390 391 392 |
# File 'lib/rbs/ast/declarations.rb', line 390 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
388 389 390 |
# File 'lib/rbs/ast/declarations.rb', line 388 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
389 390 391 |
# File 'lib/rbs/ast/declarations.rb', line 389 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
400 401 402 403 404 |
# File 'lib/rbs/ast/declarations.rb', line 400 def ==(other) other.is_a?(Constant) && other.name == name && other.type == type end |
#hash ⇒ Object
408 409 410 |
# File 'lib/rbs/ast/declarations.rb', line 408 def hash self.class.hash ^ name.hash ^ type.hash end |
#to_json(*a) ⇒ Object
412 413 414 415 416 417 418 419 420 |
# File 'lib/rbs/ast/declarations.rb', line 412 def to_json(*a) { declaration: :constant, name: name, type: type, location: location, comment: comment }.to_json(*a) end |