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(state = _ = nil) ⇒ Object
Constructor Details
#initialize(name:, type:, location:, comment:) ⇒ Constant
Returns a new instance of Constant.
317 318 319 320 321 322 |
# 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 ⇒ Object (readonly)
Returns the value of attribute comment.
315 316 317 |
# File 'lib/rbs/ast/declarations.rb', line 315 def comment @comment end |
#location ⇒ Object (readonly)
Returns the value of attribute location.
314 315 316 |
# File 'lib/rbs/ast/declarations.rb', line 314 def location @location end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
312 313 314 |
# File 'lib/rbs/ast/declarations.rb', line 312 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
313 314 315 |
# File 'lib/rbs/ast/declarations.rb', line 313 def type @type end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
324 325 326 327 328 |
# File 'lib/rbs/ast/declarations.rb', line 324 def ==(other) other.is_a?(Constant) && other.name == name && other.type == type end |
#hash ⇒ Object
332 333 334 |
# File 'lib/rbs/ast/declarations.rb', line 332 def hash self.class.hash ^ name.hash ^ type.hash end |
#to_json(state = _ = nil) ⇒ Object
336 337 338 339 340 341 342 343 344 |
# 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 |