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.
328 329 330 331 332 333 |
# File 'lib/rbs/ast/declarations.rb', line 328 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.
326 327 328 |
# File 'lib/rbs/ast/declarations.rb', line 326 def comment @comment end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
325 326 327 |
# File 'lib/rbs/ast/declarations.rb', line 325 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
323 324 325 |
# File 'lib/rbs/ast/declarations.rb', line 323 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
324 325 326 |
# File 'lib/rbs/ast/declarations.rb', line 324 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
335 336 337 338 339 |
# File 'lib/rbs/ast/declarations.rb', line 335 def ==(other) other.is_a?(Constant) && other.name == name && other.type == type end |
#hash ⇒ Object
343 344 345 |
# File 'lib/rbs/ast/declarations.rb', line 343 def hash self.class.hash ^ name.hash ^ type.hash end |
#to_json(*a) ⇒ Object
347 348 349 350 351 352 353 354 355 |
# File 'lib/rbs/ast/declarations.rb', line 347 def to_json(*a) { declaration: :constant, name: name, type: type, location: location, comment: comment }.to_json(*a) end |