Class: RBS::AST::Comment
- Inherits:
-
Object
- Object
- RBS::AST::Comment
- Defined in:
- lib/rbs/ast/comment.rb
Instance Attribute Summary collapse
-
#location ⇒ Object
readonly
Returns the value of attribute location.
-
#string ⇒ Object
readonly
Returns the value of attribute string.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #concat(string:, location:) ⇒ Object
- #hash ⇒ Object
-
#initialize(string:, location:) ⇒ Comment
constructor
A new instance of Comment.
- #to_json(*a) ⇒ Object
Constructor Details
#initialize(string:, location:) ⇒ Comment
Returns a new instance of Comment.
7 8 9 10 |
# File 'lib/rbs/ast/comment.rb', line 7 def initialize(string:, location:) @string = string @location = location end |
Instance Attribute Details
#location ⇒ Object (readonly)
Returns the value of attribute location.
5 6 7 |
# File 'lib/rbs/ast/comment.rb', line 5 def location @location end |
#string ⇒ Object (readonly)
Returns the value of attribute string.
4 5 6 |
# File 'lib/rbs/ast/comment.rb', line 4 def string @string end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
12 13 14 |
# File 'lib/rbs/ast/comment.rb', line 12 def ==(other) other.is_a?(Comment) && other.string == string end |
#concat(string:, location:) ⇒ Object
26 27 28 29 30 |
# File 'lib/rbs/ast/comment.rb', line 26 def concat(string:, location:) @string.concat string @location.concat location self end |
#hash ⇒ Object
18 19 20 |
# File 'lib/rbs/ast/comment.rb', line 18 def hash self.class.hash ^ string.hash end |
#to_json(*a) ⇒ Object
22 23 24 |
# File 'lib/rbs/ast/comment.rb', line 22 def to_json(*a) { string: string, location: location }.to_json(*a) end |