Class
This represents a comment that was encountered during parsing. It is the base class for all comment types.
Attributes
Read
The location of this comment in the source.
Class Methods
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 371
def initialize(location)
@location = location
end
Create a new comment object with the given location.
Instance Methods
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 376
def deconstruct_keys(keys)
{ location: location }
end
Implement the hash pattern matching interface for Comment
.
#
lib/prism/parse_result.rb
View on GitHub
# File tmp/rubies/ruby-3.4.0-preview1/lib/prism/parse_result.rb, line 381
def slice
location.slice
end
Returns the content of the comment by slicing it from the source code.